Skip to content

Commit eb3e6fb

Browse files
authored
Merge branch 'canary' into feat/transform-runtime-version
2 parents fad8b42 + eb38d22 commit eb3e6fb

File tree

9 files changed

+248
-11
lines changed

9 files changed

+248
-11
lines changed

packages/next/build/webpack-config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ function getOptimizedAliases(isServer: boolean): { [pkg: string]: string } {
8787
'object.assign/shim': path.join(shimAssign, 'shim.js'),
8888

8989
// Replace: full URL polyfill with platform-based polyfill
90-
url: require.resolve('native-url'),
90+
// url: require.resolve('native-url'),
9191
}
9292
}
9393

packages/next/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@
109109
"lru-cache": "5.1.1",
110110
"mini-css-extract-plugin": "0.8.0",
111111
"mkdirp": "0.5.1",
112-
"native-url": "0.2.4",
113112
"node-fetch": "2.6.0",
114113
"object-assign": "4.1.1",
115114
"ora": "3.4.0",
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
const Index = ({ query }) => (
2+
<pre id="query-content">{JSON.stringify(query)}</pre>
3+
)
4+
5+
Index.getInitialProps = ({ query }) => ({ query })
6+
7+
export default Index
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import Link from 'next/link'
2+
3+
const Another = () => (
4+
<div>
5+
<Link href="/?another=hello%0A">
6+
<a id="hello-lf">Hello LF</a>
7+
</Link>
8+
<br />
9+
<Link href={{ pathname: '/', query: { complex: 'yes\n' } }}>
10+
<a id="hello-complex">Hello Complex</a>
11+
</Link>
12+
</div>
13+
)
14+
15+
export default Another
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import Link from 'next/link'
2+
3+
const Another = () => (
4+
<div>
5+
<Link href="/?another=hello%25">
6+
<a id="hello-percent">Hello %</a>
7+
</Link>
8+
<br />
9+
<Link href={{ pathname: '/', query: { complex: 'yes%' } }}>
10+
<a id="hello-complex">Hello Complex</a>
11+
</Link>
12+
</div>
13+
)
14+
15+
export default Another
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import Link from 'next/link'
2+
3+
const Another = () => (
4+
<div>
5+
<Link href="/?another=hello%20">
6+
<a id="hello-space">Hello Space</a>
7+
</Link>
8+
<br />
9+
<Link href={{ pathname: '/', query: { complex: 'yes ' } }}>
10+
<a id="hello-complex">Hello Complex</a>
11+
</Link>
12+
</div>
13+
)
14+
15+
export default Another
Lines changed: 193 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
/* eslint-env jest */
2+
/* global jasmine */
3+
import {
4+
nextBuild,
5+
nextServer,
6+
startApp,
7+
stopApp,
8+
waitFor,
9+
} from 'next-test-utils'
10+
import webdriver from 'next-webdriver'
11+
import { join } from 'path'
12+
13+
jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000 * 60 * 2
14+
15+
const appDir = join(__dirname, '..')
16+
17+
let appPort
18+
let app
19+
let server
20+
21+
describe('Query String with Encoding', () => {
22+
beforeAll(async () => {
23+
await nextBuild(appDir)
24+
app = nextServer({
25+
dir: join(__dirname, '../'),
26+
dev: false,
27+
quiet: true,
28+
})
29+
30+
server = await startApp(app)
31+
appPort = server.address().port
32+
})
33+
afterAll(() => stopApp(server))
34+
35+
describe('new line', () => {
36+
it('should have correct query on SSR', async () => {
37+
const browser = await webdriver(appPort, '/?test=abc%0A')
38+
try {
39+
const text = await browser.elementByCss('#query-content').text()
40+
expect(text).toBe('{"test":"abc\\n"}')
41+
} finally {
42+
await browser.close()
43+
}
44+
})
45+
46+
it('should have correct query on Router#push', async () => {
47+
const browser = await webdriver(appPort, '/')
48+
try {
49+
await waitFor(2000)
50+
await browser.eval(
51+
`window.next.router.push({pathname:'/',query:{abc:'def\\n'}})`
52+
)
53+
await waitFor(1000)
54+
const text = await browser.elementByCss('#query-content').text()
55+
expect(text).toBe('{"abc":"def\\n"}')
56+
} finally {
57+
await browser.close()
58+
}
59+
})
60+
61+
it('should have correct query on simple client-side <Link>', async () => {
62+
const browser = await webdriver(appPort, '/newline')
63+
try {
64+
await waitFor(2000)
65+
await browser.elementByCss('#hello-lf').click()
66+
await waitFor(1000)
67+
const text = await browser.elementByCss('#query-content').text()
68+
expect(text).toBe('{"another":"hello\\n"}')
69+
} finally {
70+
await browser.close()
71+
}
72+
})
73+
74+
it('should have correct query on complex client-side <Link>', async () => {
75+
const browser = await webdriver(appPort, '/newline')
76+
try {
77+
await waitFor(2000)
78+
await browser.elementByCss('#hello-complex').click()
79+
await waitFor(1000)
80+
const text = await browser.elementByCss('#query-content').text()
81+
expect(text).toBe('{"complex":"yes\\n"}')
82+
} finally {
83+
await browser.close()
84+
}
85+
})
86+
})
87+
88+
describe('trailing space', () => {
89+
it('should have correct query on SSR', async () => {
90+
const browser = await webdriver(appPort, '/?test=abc%20')
91+
try {
92+
const text = await browser.elementByCss('#query-content').text()
93+
expect(text).toBe('{"test":"abc "}')
94+
} finally {
95+
await browser.close()
96+
}
97+
})
98+
99+
it('should have correct query on Router#push', async () => {
100+
const browser = await webdriver(appPort, '/')
101+
try {
102+
await waitFor(2000)
103+
await browser.eval(
104+
`window.next.router.push({pathname:'/',query:{abc:'def '}})`
105+
)
106+
await waitFor(1000)
107+
const text = await browser.elementByCss('#query-content').text()
108+
expect(text).toBe('{"abc":"def "}')
109+
} finally {
110+
await browser.close()
111+
}
112+
})
113+
114+
it('should have correct query on simple client-side <Link>', async () => {
115+
const browser = await webdriver(appPort, '/space')
116+
try {
117+
await waitFor(2000)
118+
await browser.elementByCss('#hello-space').click()
119+
await waitFor(1000)
120+
const text = await browser.elementByCss('#query-content').text()
121+
expect(text).toBe('{"another":"hello "}')
122+
} finally {
123+
await browser.close()
124+
}
125+
})
126+
127+
it('should have correct query on complex client-side <Link>', async () => {
128+
const browser = await webdriver(appPort, '/space')
129+
try {
130+
await waitFor(2000)
131+
await browser.elementByCss('#hello-complex').click()
132+
await waitFor(1000)
133+
const text = await browser.elementByCss('#query-content').text()
134+
expect(text).toBe('{"complex":"yes "}')
135+
} finally {
136+
await browser.close()
137+
}
138+
})
139+
})
140+
141+
describe('percent', () => {
142+
it('should have correct query on SSR', async () => {
143+
const browser = await webdriver(appPort, '/?test=abc%25')
144+
try {
145+
const text = await browser.elementByCss('#query-content').text()
146+
expect(text).toBe('{"test":"abc%"}')
147+
} finally {
148+
await browser.close()
149+
}
150+
})
151+
152+
it('should have correct query on Router#push', async () => {
153+
const browser = await webdriver(appPort, '/')
154+
try {
155+
await waitFor(2000)
156+
await browser.eval(
157+
`window.next.router.push({pathname:'/',query:{abc:'def%'}})`
158+
)
159+
await waitFor(1000)
160+
const text = await browser.elementByCss('#query-content').text()
161+
expect(text).toBe('{"abc":"def%"}')
162+
} finally {
163+
await browser.close()
164+
}
165+
})
166+
167+
it('should have correct query on simple client-side <Link>', async () => {
168+
const browser = await webdriver(appPort, '/percent')
169+
try {
170+
await waitFor(2000)
171+
await browser.elementByCss('#hello-percent').click()
172+
await waitFor(1000)
173+
const text = await browser.elementByCss('#query-content').text()
174+
expect(text).toBe('{"another":"hello%"}')
175+
} finally {
176+
await browser.close()
177+
}
178+
})
179+
180+
it('should have correct query on complex client-side <Link>', async () => {
181+
const browser = await webdriver(appPort, '/percent')
182+
try {
183+
await waitFor(2000)
184+
await browser.elementByCss('#hello-complex').click()
185+
await waitFor(1000)
186+
const text = await browser.elementByCss('#query-content').text()
187+
expect(text).toBe('{"complex":"yes%"}')
188+
} finally {
189+
await browser.close()
190+
}
191+
})
192+
})
193+
})

test/integration/size-limit/test/index.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ describe('Production response size', () => {
8181
)
8282

8383
// These numbers are without gzip compression!
84-
const delta = responseSizeKilobytes - 228
84+
const delta = responseSizeKilobytes - 234
8585
expect(delta).toBeLessThanOrEqual(0) // don't increase size
8686
expect(delta).toBeGreaterThanOrEqual(-1) // don't decrease size without updating target
8787
})
@@ -101,7 +101,7 @@ describe('Production response size', () => {
101101
)
102102

103103
// These numbers are without gzip compression!
104-
const delta = responseSizeKilobytes - 196
104+
const delta = responseSizeKilobytes - 203
105105
expect(delta).toBeLessThanOrEqual(0) // don't increase size
106106
expect(delta).toBeGreaterThanOrEqual(-1) // don't decrease size without updating target
107107
})

yarn.lock

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10079,13 +10079,6 @@ native-or-bluebird@^1.2.0:
1007910079
resolved "https://registry.yarnpkg.com/native-or-bluebird/-/native-or-bluebird-1.2.0.tgz#39c47bfd7825d1fb9ffad32210ae25daadf101c9"
1008010080
integrity sha1-OcR7/Xgl0fuf+tMiEK4l2q3xAck=
1008110081

10082-
10083-
version "0.2.4"
10084-
resolved "https://registry.yarnpkg.com/native-url/-/native-url-0.2.4.tgz#37623b3db2c7bb6670e50e379634248ba5ca9d90"
10085-
integrity sha512-McE+8BrgMw2ANypdYX9s1L+aUkbWDCEtsBGIbs8TfKBfQrFcZ2jMXX9LxGjOIOtoRXkwLTSlz38XHm8J3U6hgQ==
10086-
dependencies:
10087-
querystring "^0.2.0"
10088-
1008910082
natural-compare@^1.4.0:
1009010083
version "1.4.0"
1009110084
resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7"

0 commit comments

Comments
 (0)