-
Notifications
You must be signed in to change notification settings - Fork 27k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(turbopack): correctly handle catchall specificity (#68800)
(generated by graphite) ### What? Introduce `get_specificity` method to determine the specificity of routes. This facilitates more accurate route matching for catchall routes by comparing route specificity. Modify existing route matching logic to incorporate specificity checks and avoid route conflicts. Add corresponding tests to validate the new specificity handling mechanism. Fixes #67045 Closes PACK-3154
- Loading branch information
1 parent
15aeb92
commit aa90fe9
Showing
6 changed files
with
62 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
test/e2e/app-dir/catchall-specificity/app/(group)/specific/[[...slug]]/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default function Page() { | ||
return <div>Specific Page</div> | ||
} |
3 changes: 3 additions & 0 deletions
3
test/e2e/app-dir/catchall-specificity/app/[[...slug]]/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default function Page() { | ||
return <div>Generic Page</div> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { ReactNode } from 'react' | ||
|
||
export default function Root({ children }: { children: ReactNode }) { | ||
return ( | ||
<html> | ||
<body>{children}</body> | ||
</html> | ||
) | ||
} |
19 changes: 19 additions & 0 deletions
19
test/e2e/app-dir/catchall-specificity/catchall-specificity.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { nextTestSetup } from 'e2e-utils' | ||
|
||
describe('catchall-specificity', () => { | ||
const { next } = nextTestSetup({ | ||
files: __dirname, | ||
}) | ||
|
||
it('should match the generic catchall correctly', async () => { | ||
const browser = await next.browser('/foo') | ||
|
||
expect(await browser.elementByCss('body').text()).toContain('Generic Page') | ||
}) | ||
|
||
it('should match the specific catchall correctly', async () => { | ||
const browser = await next.browser('/specific') | ||
|
||
expect(await browser.elementByCss('body').text()).toContain('Specific Page') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/** | ||
* @type {import('next').NextConfig} | ||
*/ | ||
const nextConfig = {} | ||
|
||
module.exports = nextConfig |