Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
fbc20a54
Commit
fbc20a54
authored
Jun 13, 2019
by
JJ Kasper
Committed by
Joe Haddad
Jun 13, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Strip queries before matching route on client (#7566)
parent
7132995a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
1 deletion
+14
-1
router.ts
packages/next-server/lib/router/router.ts
+2
-1
index.js
test/integration/dynamic-routing/pages/index.js
+4
-0
index.test.js
test/integration/dynamic-routing/test/index.test.js
+8
-0
No files found.
packages/next-server/lib/router/router.ts
View file @
fbc20a54
...
@@ -275,8 +275,9 @@ export default class Router implements BaseRouter {
...
@@ -275,8 +275,9 @@ export default class Router implements BaseRouter {
// detect dynamic routing
// detect dynamic routing
if
(
route
.
indexOf
(
'/$'
)
!==
-
1
)
{
if
(
route
.
indexOf
(
'/$'
)
!==
-
1
)
{
const
{
pathname
:
asPathname
}
=
parse
(
as
)
const
rr
=
getRouteRegex
(
route
)
const
rr
=
getRouteRegex
(
route
)
const
routeMatch
=
getRouteMatcher
(
rr
)(
as
)
const
routeMatch
=
getRouteMatcher
(
rr
)(
as
Pathname
)
if
(
!
routeMatch
)
{
if
(
!
routeMatch
)
{
console
.
error
(
console
.
error
(
"Your `<Link>`'s `as` value is incompatible with the `href` value. This is invalid."
"Your `<Link>`'s `as` value is incompatible with the `href` value. This is invalid."
...
...
test/integration/dynamic-routing/pages/index.js
View file @
fbc20a54
...
@@ -22,6 +22,10 @@ const Page = () => (
...
@@ -22,6 +22,10 @@ const Page = () => (
<
Link
href
=
'/blog/$post/comment/$id'
as
=
'/blog/321/comment/123'
>
<
Link
href
=
'/blog/$post/comment/$id'
as
=
'/blog/321/comment/123'
>
<
a
id
=
'view-nested-dynamic-cmnt'
>
View
comment
123
on
blog
post
321
<
/a
>
<
a
id
=
'view-nested-dynamic-cmnt'
>
View
comment
123
on
blog
post
321
<
/a
>
<
/Link
>
<
/Link
>
<
br
/>
<
Link
href
=
'/$post?fromHome=true'
as
=
'/post-1?fromHome=true'
>
<
a
id
=
'view-post-1-with-query'
>
View
post
1
with
query
<
/a
>
<
/Link
>
<
/div
>
<
/div
>
)
)
...
...
test/integration/dynamic-routing/test/index.test.js
View file @
fbc20a54
...
@@ -58,6 +58,14 @@ function runTests () {
...
@@ -58,6 +58,14 @@ function runTests () {
expect
(
html
).
toMatch
(
/blog post.*321.*comment.*123/i
)
expect
(
html
).
toMatch
(
/blog post.*321.*comment.*123/i
)
})
})
it
(
'should render dynamic route with query'
,
async
()
=>
{
const
browser
=
await
webdriver
(
appPort
,
'/'
)
await
browser
.
elementByCss
(
'#view-post-1-with-query'
).
click
()
await
waitFor
(
1000
)
const
url
=
await
browser
.
eval
(
'window.location.search'
)
expect
(
url
).
toBe
(
'?fromHome=true'
)
})
it
(
'should navigate to a dynamic page successfully'
,
async
()
=>
{
it
(
'should navigate to a dynamic page successfully'
,
async
()
=>
{
let
browser
let
browser
try
{
try
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment