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
d12272a6
Unverified
Commit
d12272a6
authored
Jul 29, 2022
by
JJ Kasper
Committed by
GitHub
Jul 29, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix incorrect component cache for middleware cases (#39159)
parent
eb0e161f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
6 deletions
+22
-6
router.ts
packages/next/shared/lib/router/router.ts
+0
-6
index.test.ts
test/e2e/middleware-rewrites/test/index.test.ts
+22
-0
No files found.
packages/next/shared/lib/router/router.ts
View file @
d12272a6
...
...
@@ -1763,7 +1763,6 @@ export default class Router implements BaseRouter {
// If we have a match with the current route due to rewrite,
// we can copy the existing information to the rewritten one.
// Then, we return the information along with the matched route.
this
.
components
[
requestedRoute
]
=
{
...
existingInfo
,
route
}
return
{
...
existingInfo
,
route
}
}
}
...
...
@@ -1908,11 +1907,6 @@ export default class Router implements BaseRouter {
routeInfo
.
resolvedAs
=
resolvedAs
this
.
components
[
route
]
=
routeInfo
// If the route was rewritten in the process of fetching data,
// we update the cache to allow hitting the same data for shallow requests.
if
(
route
!==
requestedRoute
)
{
this
.
components
[
requestedRoute
]
=
{
...
routeInfo
,
route
}
}
return
routeInfo
}
catch
(
err
)
{
return
this
.
handleRouteInfoError
(
...
...
test/e2e/middleware-rewrites/test/index.test.ts
View file @
d12272a6
...
...
@@ -27,6 +27,28 @@ describe('Middleware Rewrite', () => {
testsWithLocale
(
'/fr'
)
function
tests
()
{
it
(
'should not mix component cache when navigating between dynamic routes'
,
async
()
=>
{
const
browser
=
await
webdriver
(
next
.
url
,
'/param-1'
)
expect
(
await
browser
.
eval
(
'next.router.pathname'
)).
toBe
(
'/[param]'
)
expect
(
await
browser
.
eval
(
'next.router.query.param'
)).
toBe
(
'param-1'
)
await
browser
.
eval
(
`next.router.push("/fallback-true-blog/first")`
)
await
check
(
()
=>
browser
.
eval
(
'next.router.pathname'
),
'/fallback-true-blog/[slug]'
)
expect
(
await
browser
.
eval
(
'next.router.query.slug'
)).
toBe
(
'first'
)
expect
(
await
browser
.
eval
(
'next.router.asPath'
)).
toBe
(
'/fallback-true-blog/first'
)
await
browser
.
back
()
await
check
(()
=>
browser
.
eval
(
'next.router.pathname'
),
'/[param]'
)
expect
(
await
browser
.
eval
(
'next.router.query.param'
)).
toBe
(
'param-1'
)
expect
(
await
browser
.
eval
(
'next.router.asPath'
)).
toBe
(
'/param-1'
)
})
it
(
'should have props for afterFiles rewrite to SSG page'
,
async
()
=>
{
let
browser
=
await
webdriver
(
next
.
url
,
'/'
)
await
browser
.
eval
(
`next.router.push("/afterfiles-rewrite-ssg")`
)
...
...
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