Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
CoCo_Code_Op2
next.js
提交
ac5b2acd
N
next.js
项目概览
CoCo_Code_Op2
/
next.js
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
N
next.js
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
ac5b2acd
编写于
6月 29, 2020
作者:
J
Joe Haddad
提交者:
GitHub
6月 29, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix dynamic route encoding for NextLinks (#14281)
上级
c9bc101d
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
347 addition
and
5 deletion
+347
-5
packages/next/package.json
packages/next/package.json
+1
-1
test/integration/link-with-encoding/pages/index.js
test/integration/link-with-encoding/pages/index.js
+36
-0
test/integration/link-with-encoding/pages/single/[slug].js
test/integration/link-with-encoding/pages/single/[slug].js
+7
-0
test/integration/link-with-encoding/test/index.test.js
test/integration/link-with-encoding/test/index.test.js
+299
-0
yarn.lock
yarn.lock
+4
-4
未找到文件。
packages/next/package.json
浏览文件 @
ac5b2acd
...
...
@@ -90,7 +90,7 @@
"loader-utils"
:
"2.0.0"
,
"mini-css-extract-plugin"
:
"0.8.0"
,
"mkdirp"
:
"0.5.3"
,
"native-url"
:
"0.3.
3
"
,
"native-url"
:
"0.3.
4
"
,
"neo-async"
:
"2.6.1"
,
"pnp-webpack-plugin"
:
"1.6.4"
,
"postcss"
:
"7.0.29"
,
...
...
test/integration/link-with-encoding/pages/index.js
0 → 100644
浏览文件 @
ac5b2acd
import
Link
from
'
next/link
'
const
Home
=
()
=>
(
<
div
>
<
Link
href
=
"
/single/[slug]
"
as
=
{
encodeURI
(
'
/single/hello world
'
)}
>
<
a
id
=
"
single-spaces
"
>
Single
:
Spaces
<
/a
>
<
/Link
>
<
br
/>
<
Link
href
=
"
/single/[slug]
"
as
=
{
encodeURI
(
'
/single/hello%world
'
)}
>
<
a
id
=
"
single-percent
"
>
Single
:
Percent
<
/a
>
<
/Link
>
<
br
/>
<
Link
href
=
"
/single/[slug]
"
as
=
{
`/single/hello
${
encodeURIComponent
(
'
/
'
)}
world`
}
>
<
a
id
=
"
single-slash
"
>
Single
:
Forward
Slash
<
/a
>
<
/Link
>
<
br
/>
<
Link
href
=
"
/single/[slug]
"
as
=
{
`/single/hello
${
encodeURIComponent
(
'
"
'
)}
world`
}
>
<
a
id
=
"
single-double-quote
"
>
Single
:
"
</a>
</Link>
<br />
<Link
href=
"
/
single
/
[
slug
]
"
as={`/single/hello${encodeURIComponent(':')}world`}
>
<a id=
"
single
-
colon
"
>Single: :</a>
</Link>
</div>
)
export default Home
test/integration/link-with-encoding/pages/single/[slug].js
0 → 100644
浏览文件 @
ac5b2acd
export
function
getServerSideProps
({
params
:
{
slug
}
})
{
return
{
props
:
{
slug
}
}
}
export
default
function
Single
(
props
)
{
return
<
pre
id
=
"
query-content
"
>
{
JSON
.
stringify
(
props
)}
<
/pre
>
}
test/integration/link-with-encoding/test/index.test.js
0 → 100644
浏览文件 @
ac5b2acd
/* eslint-env jest */
import
{
findPort
,
killApp
,
launchApp
,
waitFor
,
check
}
from
'
next-test-utils
'
import
webdriver
from
'
next-webdriver
'
import
{
join
}
from
'
path
'
jest
.
setTimeout
(
1000
*
60
*
2
)
const
appDir
=
join
(
__dirname
,
'
..
'
)
let
appPort
let
app
describe
(
'
Link Component with Encoding
'
,
()
=>
{
beforeAll
(
async
()
=>
{
appPort
=
await
findPort
()
app
=
await
launchApp
(
appDir
,
appPort
)
})
afterAll
(()
=>
killApp
(
app
))
describe
(
'
spaces
'
,
()
=>
{
it
(
'
should have correct query on SSR
'
,
async
()
=>
{
const
browser
=
await
webdriver
(
appPort
,
encodeURI
(
'
/single/hello world
'
)
)
try
{
const
text
=
await
browser
.
elementByCss
(
'
#query-content
'
).
text
()
expect
(
text
).
toMatchInlineSnapshot
(
`"{\\"slug\\":\\"hello world \\"}"`
)
}
finally
{
await
browser
.
close
()
}
})
it
(
'
should have correct query on Router#push
'
,
async
()
=>
{
const
browser
=
await
webdriver
(
appPort
,
'
/
'
)
try
{
await
waitFor
(
2000
)
await
browser
.
eval
(
`window.next.router.push(
{ pathname: '/single/[slug]' },
{ pathname: encodeURI('/single/hello world ') }
)`
)
await
check
(()
=>
browser
.
hasElementByCssSelector
(
'
#query-content
'
),
{
test
(
val
)
{
return
Boolean
(
val
)
},
})
const
text
=
await
browser
.
elementByCss
(
'
#query-content
'
).
text
()
expect
(
text
).
toMatchInlineSnapshot
(
`"{\\"slug\\":\\"hello world \\"}"`
)
}
finally
{
await
browser
.
close
()
}
})
it
(
'
should have correct query on simple client-side <Link>
'
,
async
()
=>
{
const
browser
=
await
webdriver
(
appPort
,
'
/
'
)
try
{
await
waitFor
(
2000
)
await
browser
.
elementByCss
(
'
#single-spaces
'
).
click
()
await
check
(()
=>
browser
.
hasElementByCssSelector
(
'
#query-content
'
),
{
test
(
val
)
{
return
Boolean
(
val
)
},
})
const
text
=
await
browser
.
elementByCss
(
'
#query-content
'
).
text
()
expect
(
text
).
toMatchInlineSnapshot
(
`"{\\"slug\\":\\"hello world \\"}"`
)
}
finally
{
await
browser
.
close
()
}
})
})
describe
(
'
percent
'
,
()
=>
{
it
(
'
should have correct query on SSR
'
,
async
()
=>
{
const
browser
=
await
webdriver
(
appPort
,
encodeURI
(
'
/single/hello%world
'
))
try
{
const
text
=
await
browser
.
elementByCss
(
'
#query-content
'
).
text
()
expect
(
text
).
toMatchInlineSnapshot
(
`"{\\"slug\\":\\"hello%world\\"}"`
)
}
finally
{
await
browser
.
close
()
}
})
it
(
'
should have correct query on Router#push
'
,
async
()
=>
{
const
browser
=
await
webdriver
(
appPort
,
'
/
'
)
try
{
await
waitFor
(
2000
)
await
browser
.
eval
(
`window.next.router.push(
{ pathname: '/single/[slug]' },
{ pathname: encodeURI('/single/hello%world') }
)`
)
await
check
(()
=>
browser
.
hasElementByCssSelector
(
'
#query-content
'
),
{
test
(
val
)
{
return
Boolean
(
val
)
},
})
const
text
=
await
browser
.
elementByCss
(
'
#query-content
'
).
text
()
expect
(
text
).
toMatchInlineSnapshot
(
`"{\\"slug\\":\\"hello%world\\"}"`
)
}
finally
{
await
browser
.
close
()
}
})
it
(
'
should have correct query on simple client-side <Link>
'
,
async
()
=>
{
const
browser
=
await
webdriver
(
appPort
,
'
/
'
)
try
{
await
waitFor
(
2000
)
await
browser
.
elementByCss
(
'
#single-percent
'
).
click
()
await
check
(()
=>
browser
.
hasElementByCssSelector
(
'
#query-content
'
),
{
test
(
val
)
{
return
Boolean
(
val
)
},
})
const
text
=
await
browser
.
elementByCss
(
'
#query-content
'
).
text
()
expect
(
text
).
toMatchInlineSnapshot
(
`"{\\"slug\\":\\"hello%world\\"}"`
)
}
finally
{
await
browser
.
close
()
}
})
})
describe
(
'
forward slash
'
,
()
=>
{
it
(
'
should have correct query on SSR
'
,
async
()
=>
{
const
browser
=
await
webdriver
(
appPort
,
`/single/hello
${
encodeURIComponent
(
'
/
'
)}
world`
)
try
{
const
text
=
await
browser
.
elementByCss
(
'
#query-content
'
).
text
()
expect
(
text
).
toMatchInlineSnapshot
(
`"{\\"slug\\":\\"hello/world\\"}"`
)
}
finally
{
await
browser
.
close
()
}
})
it
(
'
should have correct query on Router#push
'
,
async
()
=>
{
const
browser
=
await
webdriver
(
appPort
,
'
/
'
)
try
{
await
waitFor
(
2000
)
await
browser
.
eval
(
`window.next.router.push(
{ pathname: '/single/[slug]' },
{ pathname: '/single/hello
${
encodeURIComponent
(
'
/
'
)}
world' }
)`
)
await
check
(()
=>
browser
.
hasElementByCssSelector
(
'
#query-content
'
),
{
test
(
val
)
{
return
Boolean
(
val
)
},
})
const
text
=
await
browser
.
elementByCss
(
'
#query-content
'
).
text
()
expect
(
text
).
toMatchInlineSnapshot
(
`"{\\"slug\\":\\"hello/world\\"}"`
)
}
finally
{
await
browser
.
close
()
}
})
it
(
'
should have correct query on simple client-side <Link>
'
,
async
()
=>
{
const
browser
=
await
webdriver
(
appPort
,
'
/
'
)
try
{
await
waitFor
(
2000
)
await
browser
.
elementByCss
(
'
#single-slash
'
).
click
()
await
check
(()
=>
browser
.
hasElementByCssSelector
(
'
#query-content
'
),
{
test
(
val
)
{
return
Boolean
(
val
)
},
})
const
text
=
await
browser
.
elementByCss
(
'
#query-content
'
).
text
()
expect
(
text
).
toMatchInlineSnapshot
(
`"{\\"slug\\":\\"hello/world\\"}"`
)
}
finally
{
await
browser
.
close
()
}
})
})
describe
(
'
double quote
'
,
()
=>
{
it
(
'
should have correct query on SSR
'
,
async
()
=>
{
const
browser
=
await
webdriver
(
appPort
,
`/single/hello
${
encodeURIComponent
(
'
"
'
)}
world`
)
try
{
const
text
=
await
browser
.
elementByCss
(
'
#query-content
'
).
text
()
expect
(
JSON
.
parse
(
text
)).
toMatchInlineSnapshot
(
`
Object {
"slug": "hello\\"world",
}
`
)
}
finally
{
await
browser
.
close
()
}
})
it
(
'
should have correct query on Router#push
'
,
async
()
=>
{
const
browser
=
await
webdriver
(
appPort
,
'
/
'
)
try
{
await
waitFor
(
2000
)
await
browser
.
eval
(
`window.next.router.push(
{ pathname: '/single/[slug]' },
{ pathname: '/single/hello
${
encodeURIComponent
(
'
"
'
)}
world' }
)`
)
await
check
(()
=>
browser
.
hasElementByCssSelector
(
'
#query-content
'
),
{
test
(
val
)
{
return
Boolean
(
val
)
},
})
const
text
=
await
browser
.
elementByCss
(
'
#query-content
'
).
text
()
expect
(
JSON
.
parse
(
text
)).
toMatchInlineSnapshot
(
`
Object {
"slug": "hello\\"world",
}
`
)
}
finally
{
await
browser
.
close
()
}
})
it
(
'
should have correct query on simple client-side <Link>
'
,
async
()
=>
{
const
browser
=
await
webdriver
(
appPort
,
'
/
'
)
try
{
await
waitFor
(
2000
)
await
browser
.
elementByCss
(
'
#single-double-quote
'
).
click
()
await
check
(()
=>
browser
.
hasElementByCssSelector
(
'
#query-content
'
),
{
test
(
val
)
{
return
Boolean
(
val
)
},
})
const
text
=
await
browser
.
elementByCss
(
'
#query-content
'
).
text
()
expect
(
JSON
.
parse
(
text
)).
toMatchInlineSnapshot
(
`
Object {
"slug": "hello\\"world",
}
`
)
}
finally
{
await
browser
.
close
()
}
})
})
describe
(
'
colon
'
,
()
=>
{
it
(
'
should have correct query on SSR
'
,
async
()
=>
{
const
browser
=
await
webdriver
(
appPort
,
`/single/hello
${
encodeURIComponent
(
'
:
'
)}
world`
)
try
{
const
text
=
await
browser
.
elementByCss
(
'
#query-content
'
).
text
()
expect
(
text
).
toMatchInlineSnapshot
(
`"{\\"slug\\":\\"hello:world\\"}"`
)
}
finally
{
await
browser
.
close
()
}
})
it
(
'
should have correct query on Router#push
'
,
async
()
=>
{
const
browser
=
await
webdriver
(
appPort
,
'
/
'
)
try
{
await
waitFor
(
2000
)
await
browser
.
eval
(
`window.next.router.push(
{ pathname: '/single/[slug]' },
{ pathname: '/single/hello
${
encodeURIComponent
(
'
:
'
)}
world' }
)`
)
await
check
(()
=>
browser
.
hasElementByCssSelector
(
'
#query-content
'
),
{
test
(
val
)
{
return
Boolean
(
val
)
},
})
const
text
=
await
browser
.
elementByCss
(
'
#query-content
'
).
text
()
expect
(
text
).
toMatchInlineSnapshot
(
`"{\\"slug\\":\\"hello:world\\"}"`
)
}
finally
{
await
browser
.
close
()
}
})
it
(
'
should have correct query on simple client-side <Link>
'
,
async
()
=>
{
const
browser
=
await
webdriver
(
appPort
,
'
/
'
)
try
{
await
waitFor
(
2000
)
await
browser
.
elementByCss
(
'
#single-colon
'
).
click
()
await
check
(()
=>
browser
.
hasElementByCssSelector
(
'
#query-content
'
),
{
test
(
val
)
{
return
Boolean
(
val
)
},
})
const
text
=
await
browser
.
elementByCss
(
'
#query-content
'
).
text
()
expect
(
text
).
toMatchInlineSnapshot
(
`"{\\"slug\\":\\"hello:world\\"}"`
)
}
finally
{
await
browser
.
close
()
}
})
})
})
yarn.lock
浏览文件 @
ac5b2acd
...
...
@@ -10648,10 +10648,10 @@ native-or-bluebird@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/native-or-bluebird/-/native-or-bluebird-1.2.0.tgz#39c47bfd7825d1fb9ffad32210ae25daadf101c9"
native-url@0.3.
3
:
version "0.3.
3
"
resolved "https://registry.yarnpkg.com/native-url/-/native-url-0.3.
3.tgz#09300f35416a49f79f6f8ab9e3c05c53c2873666
"
integrity sha512-
EEHLiNEIgcTjctwlREZjUT1vdMlrmug+fr0sQ3hoP9+cO3cyhd5fJ0GTnINcnv9LtXL+NdovWNUMDIfW98l2e
A==
native-url@0.3.
4
:
version "0.3.
4
"
resolved "https://registry.yarnpkg.com/native-url/-/native-url-0.3.
4.tgz#29c943172aed86c63cee62c8c04db7f5756661f8
"
integrity sha512-
6iM8R99ze45ivyH8vybJ7X0yekIcPf5GgLV5K0ENCbmRcaRIDoj37BC8iLEmaaBfqqb8enuZ5p0uhY+lVAbAc
A==
dependencies:
querystring "^0.2.0"
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录