Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/canary' into update/chunks-output
Browse files Browse the repository at this point in the history
  • Loading branch information
ijjk committed Mar 2, 2021
2 parents 7b90f18 + ac47795 commit 8857b6b
Show file tree
Hide file tree
Showing 20 changed files with 118 additions and 24 deletions.
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@
"registry": "https://registry.npmjs.org/"
}
},
"version": "10.0.8-canary.12"
"version": "10.0.8-canary.13"
}
2 changes: 1 addition & 1 deletion packages/create-next-app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "create-next-app",
"version": "10.0.8-canary.12",
"version": "10.0.8-canary.13",
"keywords": [
"react",
"next",
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin-next/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/eslint-plugin-next",
"version": "10.0.8-canary.12",
"version": "10.0.8-canary.13",
"description": "ESLint plugin for NextJS.",
"main": "lib/index.js",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/next-bundle-analyzer/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/bundle-analyzer",
"version": "10.0.8-canary.12",
"version": "10.0.8-canary.13",
"main": "index.js",
"license": "MIT",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion packages/next-codemod/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/codemod",
"version": "10.0.8-canary.12",
"version": "10.0.8-canary.13",
"license": "MIT",
"dependencies": {
"chalk": "4.1.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/next-env/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/env",
"version": "10.0.8-canary.12",
"version": "10.0.8-canary.13",
"keywords": [
"react",
"next",
Expand Down
2 changes: 1 addition & 1 deletion packages/next-mdx/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/mdx",
"version": "10.0.8-canary.12",
"version": "10.0.8-canary.13",
"main": "index.js",
"license": "MIT",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion packages/next-plugin-google-analytics/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/plugin-google-analytics",
"version": "10.0.8-canary.12",
"version": "10.0.8-canary.13",
"repository": {
"url": "vercel/next.js",
"directory": "packages/next-plugin-google-analytics"
Expand Down
2 changes: 1 addition & 1 deletion packages/next-plugin-sentry/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/plugin-sentry",
"version": "10.0.8-canary.12",
"version": "10.0.8-canary.13",
"repository": {
"url": "vercel/next.js",
"directory": "packages/next-plugin-sentry"
Expand Down
2 changes: 1 addition & 1 deletion packages/next-plugin-storybook/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/plugin-storybook",
"version": "10.0.8-canary.12",
"version": "10.0.8-canary.13",
"repository": {
"url": "vercel/next.js",
"directory": "packages/next-plugin-storybook"
Expand Down
2 changes: 1 addition & 1 deletion packages/next-polyfill-module/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/polyfill-module",
"version": "10.0.8-canary.12",
"version": "10.0.8-canary.13",
"description": "A standard library polyfill for ES Modules supporting browsers (Edge 16+, Firefox 60+, Chrome 61+, Safari 10.1+)",
"main": "dist/polyfill-module.js",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/next-polyfill-nomodule/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/polyfill-nomodule",
"version": "10.0.8-canary.12",
"version": "10.0.8-canary.13",
"description": "A polyfill for non-dead, nomodule browsers.",
"main": "dist/polyfill-nomodule.js",
"license": "MIT",
Expand Down
8 changes: 4 additions & 4 deletions packages/next/next-server/server/next-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -369,10 +369,9 @@ export default class Server {
// interpolate dynamic params and normalize URL if needed
if (pageIsDynamic) {
let params: ParsedUrlQuery | false = {}
const paramsResult = utils.normalizeDynamicRouteParams({
...parsedUrl.query,
...query,
})

Object.assign(parsedUrl.query, query)
const paramsResult = utils.normalizeDynamicRouteParams(parsedUrl.query)

if (paramsResult.hasValidParams) {
params = paramsResult.params
Expand Down Expand Up @@ -407,6 +406,7 @@ export default class Server {
pathname: matchedPathname,
})
}

Object.assign(parsedUrl.query, params)
utils.normalizeVercelUrl(req, true)
}
Expand Down
12 changes: 6 additions & 6 deletions packages/next/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "next",
"version": "10.0.8-canary.12",
"version": "10.0.8-canary.13",
"description": "The React Framework",
"main": "./dist/server/next.js",
"license": "MIT",
Expand Down Expand Up @@ -62,10 +62,10 @@
"dependencies": {
"@babel/runtime": "7.12.5",
"@hapi/accept": "5.0.1",
"@next/env": "10.0.8-canary.12",
"@next/polyfill-module": "10.0.8-canary.12",
"@next/react-dev-overlay": "10.0.8-canary.12",
"@next/react-refresh-utils": "10.0.8-canary.12",
"@next/env": "10.0.8-canary.13",
"@next/polyfill-module": "10.0.8-canary.13",
"@next/react-dev-overlay": "10.0.8-canary.13",
"@next/react-refresh-utils": "10.0.8-canary.13",
"@opentelemetry/api": "0.14.0",
"ast-types": "0.13.2",
"browserslist": "4.16.1",
Expand Down Expand Up @@ -133,7 +133,7 @@
"@babel/preset-react": "7.12.10",
"@babel/preset-typescript": "7.12.7",
"@babel/types": "7.12.12",
"@next/polyfill-nomodule": "10.0.8-canary.12",
"@next/polyfill-nomodule": "10.0.8-canary.13",
"@taskr/clear": "1.1.0",
"@taskr/esnext": "1.1.0",
"@taskr/watch": "1.1.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/react-dev-overlay/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/react-dev-overlay",
"version": "10.0.8-canary.12",
"version": "10.0.8-canary.13",
"description": "A development-only overlay for developing React applications.",
"repository": {
"url": "vercel/next.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/react-refresh-utils/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/react-refresh-utils",
"version": "10.0.8-canary.12",
"version": "10.0.8-canary.13",
"description": "An experimental package providing utilities for React Refresh.",
"repository": {
"url": "vercel/next.js",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default (req, res) => {
console.log(req.url, 'query', req.query)
res.json({
url: req.url,
query: req.query,
})
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
export const getStaticProps = ({ params }) => {
return {
props: {
random: Math.random(),
params: params || null,
},
revalidate: 1,
}
}

export const getStaticPaths = () => {
return {
paths: [],
fallback: true,
}
}

export default function Page(props) {
return <p id="props">{JSON.stringify(props)}</p>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export const getServerSideProps = ({ query, params }) => {
return {
props: {
random: Math.random(),
query: query,
params: params || null,
},
}
}

export default function Page(props) {
return <p id="props">{JSON.stringify(props)}</p>
}
54 changes: 54 additions & 0 deletions test/integration/required-server-files/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -448,4 +448,58 @@ describe('Required Server Files', () => {
expect(errors.length).toBe(1)
expect(errors[0].message).toContain('gsp hit an oops')
})

it('should normalize optional values correctly for SSP page', async () => {
const res = await fetchViaHTTP(
appPort,
'/optional-ssp',
{ rest: '', another: 'value' },
{
headers: {
'x-matched-path': '/optional-ssp/[[...rest]]',
},
}
)

const html = await res.text()
const $ = cheerio.load(html)
const props = JSON.parse($('#props').text())
expect(props.params).toEqual({})
expect(props.query).toEqual({ another: 'value' })
})

it('should normalize optional values correctly for SSG page', async () => {
const res = await fetchViaHTTP(
appPort,
'/optional-ssg',
{ rest: '', another: 'value' },
{
headers: {
'x-matched-path': '/optional-ssg/[[...rest]]',
},
}
)

const html = await res.text()
const $ = cheerio.load(html)
const props = JSON.parse($('#props').text())
expect(props.params).toEqual({})
})

it('should normalize optional values correctly for API page', async () => {
const res = await fetchViaHTTP(
appPort,
'/api/optional',
{ rest: '', another: 'value' },
{
headers: {
'x-matched-path': '/api/optional/[[...rest]]',
},
}
)

const json = await res.json()
expect(json.query).toEqual({ another: 'value' })
expect(json.url).toBe('/api/optional?another=value')
})
})

0 comments on commit 8857b6b

Please sign in to comment.