File tree Expand file tree Collapse file tree 3 files changed +24
-1
lines changed
packages/next/shared/lib/router
test/integration/dynamic-routing Expand file tree Collapse file tree 3 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -833,7 +833,9 @@ export default class Router implements BaseRouter {
833
833
return false
834
834
}
835
835
const shouldResolveHref =
836
- url === as || ( options as any ) . _h || ( options as any ) . _shouldResolveHref
836
+ ( options as any ) . _h ||
837
+ ( options as any ) . _shouldResolveHref ||
838
+ pathNoQueryHash ( url ) === pathNoQueryHash ( as )
837
839
838
840
// for static pages with query params in the URL we delay
839
841
// marking the router ready until after the query is updated
Original file line number Diff line number Diff line change @@ -26,6 +26,10 @@ const Page = () => {
26
26
< a id = "view-post-1-hash-1-href-only" > View post 1 (hash only href)</ a >
27
27
</ Link >
28
28
< br />
29
+ < Link href = "/post-1?hidden=value" as = "/post-1" >
30
+ < a id = "view-post-1-hidden-query" > View post 1 (href query)</ a >
31
+ </ Link >
32
+ < br />
29
33
< Link
30
34
href = { {
31
35
hash : 'my-hash' ,
Original file line number Diff line number Diff line change @@ -368,6 +368,23 @@ function runTests(dev) {
368
368
}
369
369
} )
370
370
371
+ it ( 'should navigate to a dynamic page with href with differing query and as correctly' , async ( ) => {
372
+ let browser
373
+ try {
374
+ browser = await webdriver ( appPort , '/' )
375
+ await browser . eval ( 'window.beforeNav = 1' )
376
+ await browser . elementByCss ( '#view-post-1-hidden-query' ) . click ( )
377
+ await browser . waitForElementByCss ( '#asdf' )
378
+
379
+ expect ( await browser . eval ( 'window.beforeNav' ) ) . toBe ( 1 )
380
+
381
+ const text = await browser . elementByCss ( '#asdf' ) . text ( )
382
+ expect ( text ) . toMatch ( / t h i s i s .* ?p o s t - 1 / i)
383
+ } finally {
384
+ if ( browser ) await browser . close ( )
385
+ }
386
+ } )
387
+
371
388
it ( 'should navigate to a dynamic page successfully no as' , async ( ) => {
372
389
let browser
373
390
try {
You can’t perform that action at this time.
0 commit comments