Skip to content

Commit

Permalink
Merge branch 'canary' into feature/make-nextconfig-keys-optional
Browse files Browse the repository at this point in the history
  • Loading branch information
ijjk committed May 18, 2021
2 parents be3123e + 5f30df2 commit a93e6ef
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 14 deletions.
4 changes: 4 additions & 0 deletions packages/next/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ Our [Code of Conduct](https://github.com/vercel/next.js/blob/canary/CODE_OF_COND

Please see our [contributing.md](/contributing.md).

### Good First Issues

We have a list of [good first issues](https://github.com/vercel/next.js/labels/good%20first%20issue) that contain bugs which have a relatively limited scope. This is a great place to get started, gain experience, and get familiar with our contribution process.

## Authors

- Tim Neutkens ([@timneutkens](https://twitter.com/timneutkens)) – [Vercel](https://vercel.com/about/timneutkens)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,23 +280,23 @@ export function getUtils({

function normalizeDynamicRouteParams(params: ParsedUrlQuery) {
let hasValidParams = true
if (!defaultRouteRegex) return { params, hasValidParams }
if (!defaultRouteRegex) return { params, hasValidParams: false }

params = Object.keys(defaultRouteRegex.groups).reduce((prev, key) => {
let value: string | string[] | undefined = params[key]

// if the value matches the default value we can't rely
// on the parsed params, this is used to signal if we need
// to parse x-now-route-matches or not
const isDefaultValue = Array.isArray(value)
? value.some((val) => {
const defaultValue = defaultRouteMatches![key]
const defaultValue = defaultRouteMatches![key]

return Array.isArray(defaultValue)
? defaultValue.includes(val)
: defaultValue === val
const isDefaultValue = Array.isArray(defaultValue)
? defaultValue.some((defaultVal) => {
return Array.isArray(value)
? value.some((val) => val.includes(defaultVal))
: value?.includes(defaultVal)
})
: value === defaultRouteMatches![key]
: value?.includes(defaultValue as string)

if (isDefaultValue || typeof value === 'undefined') {
hasValidParams = false
Expand Down
2 changes: 1 addition & 1 deletion packages/next/client/dev/dev-build-watcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export default function initializeBuildWatcher(toggleCallback) {
case 'built':
case 'sync':
isBuilding = false
// Wait for the fade out transtion to complete
// Wait for the fade out transition to complete
timeoutId = setTimeout(() => {
isVisible = false
updateContainer()
Expand Down
11 changes: 6 additions & 5 deletions packages/next/next-server/lib/router/utils/resolve-rewrites.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,13 @@ export default function resolveRewrites(
headers: {
host: document.location.hostname,
},
cookies: Object.fromEntries(
document.cookie.split('; ').map((item) => {
cookies: document.cookie
.split('; ')
.reduce<Record<string, string>>((acc, item) => {
const [key, ...value] = item.split('=')
return [key, value.join('=')]
})
),
acc[key] = value.join('=')
return acc
}, {}),
} as any,
rewrite.has,
parsedAs.query
Expand Down
14 changes: 14 additions & 0 deletions test/integration/required-server-files/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,20 @@ describe('Required Server Files', () => {
expect($2('#slug').text()).toBe('second')
expect(isNaN(data2.random)).toBe(false)
expect(data2.random).not.toBe(data.random)

const html3 = await renderViaHTTP(appPort, '/some-other-path', undefined, {
headers: {
'x-matched-path': '/dynamic/[slug]?slug=%5Bslug%5D.json',
'x-now-route-matches': '1=second&slug=second',
},
})
const $3 = cheerio.load(html3)
const data3 = JSON.parse($3('#props').text())

expect($3('#dynamic').text()).toBe('dynamic page')
expect($3('#slug').text()).toBe('second')
expect(isNaN(data3.random)).toBe(false)
expect(data3.random).not.toBe(data.random)
})

it('should render fallback page correctly with x-matched-path and routes-matches', async () => {
Expand Down

0 comments on commit a93e6ef

Please sign in to comment.