Unverified Commit 3a49a29a authored by Shu Uesugi's avatar Shu Uesugi Committed by GitHub

If prefetching detected as app route, pass "as" to handleHardNavigation instead of "url" (#47949)

### Fixing a bug

Follow-up to https://github.com/vercel/next.js/pull/47761: It seems that
`handleHardNavigation` needs to take `as` instead of `url`, in order to
be consistent with the rest of the code.

Without this, it seems to cause an issue if you are using a link that
uses legacy `as` prop which matches the bloom filter (and therefore
`__appRouter` is set as `true`).

However, I spent couple hours trying to come up with a failing test case
without this change but unfortunately couldn't come up with one.

x-ref: [Slack
Thread](https://vercel.slack.com/archives/C017QMYC5FB/p1680668865572729?thread_ts=1680225393.243459&cid=C017QMYC5FB)
Co-authored-by: 's avatarJJ Kasper <jj@jjsweb.site>
parent 89e30409
...@@ -1323,7 +1323,7 @@ export default class Router implements BaseRouter { ...@@ -1323,7 +1323,7 @@ export default class Router implements BaseRouter {
// if we detected the path as app route during prefetching // if we detected the path as app route during prefetching
// trigger hard navigation // trigger hard navigation
if ((this.components[pathname] as any)?.__appRouter) { if ((this.components[pathname] as any)?.__appRouter) {
handleHardNavigation({ url, router: this }) handleHardNavigation({ url: as, router: this })
return new Promise(() => {}) return new Promise(() => {})
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment