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
50c75282
Unverified
Commit
50c75282
authored
Sep 21, 2021
by
JJ Kasper
Committed by
GitHub
Sep 21, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix resolving href with query and matching as (#29246)
parent
8e52126e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
1 deletion
+24
-1
router.ts
packages/next/shared/lib/router/router.ts
+3
-1
index.js
test/integration/dynamic-routing/pages/index.js
+4
-0
index.test.js
test/integration/dynamic-routing/test/index.test.js
+17
-0
No files found.
packages/next/shared/lib/router/router.ts
View file @
50c75282
...
@@ -833,7 +833,9 @@ export default class Router implements BaseRouter {
...
@@ -833,7 +833,9 @@ export default class Router implements BaseRouter {
return
false
return
false
}
}
const
shouldResolveHref
=
const
shouldResolveHref
=
url
===
as
||
(
options
as
any
).
_h
||
(
options
as
any
).
_shouldResolveHref
(
options
as
any
).
_h
||
(
options
as
any
).
_shouldResolveHref
||
pathNoQueryHash
(
url
)
===
pathNoQueryHash
(
as
)
// for static pages with query params in the URL we delay
// for static pages with query params in the URL we delay
// marking the router ready until after the query is updated
// marking the router ready until after the query is updated
...
...
test/integration/dynamic-routing/pages/index.js
View file @
50c75282
...
@@ -26,6 +26,10 @@ const Page = () => {
...
@@ -26,6 +26,10 @@ const Page = () => {
<
a
id
=
"view-post-1-hash-1-href-only"
>
View
post
1
(
hash
only
href
)
<
/a
>
<
a
id
=
"view-post-1-hash-1-href-only"
>
View
post
1
(
hash
only
href
)
<
/a
>
<
/Link
>
<
/Link
>
<
br
/>
<
br
/>
<
Link
href
=
"/post-1?hidden=value"
as
=
"/post-1"
>
<
a
id
=
"view-post-1-hidden-query"
>
View
post
1
(
href
query
)
<
/a
>
<
/Link
>
<
br
/>
<
Link
<
Link
href
=
{{
href
=
{{
hash
:
'my-hash'
,
hash
:
'my-hash'
,
...
...
test/integration/dynamic-routing/test/index.test.js
View file @
50c75282
...
@@ -368,6 +368,23 @@ function runTests(dev) {
...
@@ -368,6 +368,23 @@ function runTests(dev) {
}
}
})
})
it
(
'should navigate to a dynamic page with href with differing query and as correctly'
,
async
()
=>
{
let
browser
try
{
browser
=
await
webdriver
(
appPort
,
'/'
)
await
browser
.
eval
(
'window.beforeNav = 1'
)
await
browser
.
elementByCss
(
'#view-post-1-hidden-query'
).
click
()
await
browser
.
waitForElementByCss
(
'#asdf'
)
expect
(
await
browser
.
eval
(
'window.beforeNav'
)).
toBe
(
1
)
const
text
=
await
browser
.
elementByCss
(
'#asdf'
).
text
()
expect
(
text
).
toMatch
(
/this is.*
?
post-1/i
)
}
finally
{
if
(
browser
)
await
browser
.
close
()
}
})
it
(
'should navigate to a dynamic page successfully no as'
,
async
()
=>
{
it
(
'should navigate to a dynamic page successfully no as'
,
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