mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
## For Contributors ### Fixing a bug Fixes #72523 Related tob914ad8Related to #51787 ## For Maintainers - Fixes catch-all segments in intercepted routes. ### What? The regex replacement, also replaces `...` with `_`. Which causes the check below, which handles catch-all segments, to always return false. ``` const paramName = capture.replace(/\W+/g, '_'); ``` ### Why? Currently when you have an intercepted route with a catch-all segment, it only matches the first segment. As soon as you navigate to `/multiple/segments` the intercept fails because the rewrite is not capturing this correctly. ### How? The changes introduced inb914ad8added a `replace(/\W+/g, '_')` which causes the check below to always fail, since if it started with `...` that would at that point be replaced with `_`. ### Todo - [ ] write tests to verify the return value of `rewrites` has `:path*` instead of `:path` --------- Co-authored-by: Zack Tanner <[email protected]>
42 lines
1.7 KiB
TypeScript
42 lines
1.7 KiB
TypeScript
import { nextTestSetup } from 'e2e-utils'
|
|
|
|
describe('interception-routes-multiple-catchall', () => {
|
|
const { next } = nextTestSetup({
|
|
files: __dirname,
|
|
})
|
|
|
|
describe('multi-param catch-all', () => {
|
|
it('should intercept when navigating to the same path with route interception', async () => {
|
|
const browser = await next.browser('/templates/multi/slug')
|
|
await browser.elementByCss("[href='/showcase/multi/slug']").click()
|
|
await browser.waitForElementByCss('#intercepting-page')
|
|
})
|
|
|
|
it('should intercept when navigating to a single param path', async () => {
|
|
const browser = await next.browser('/templates/multi/slug')
|
|
await browser.elementByCss("[href='/showcase/single']").click()
|
|
await browser.waitForElementByCss('#intercepting-page')
|
|
})
|
|
|
|
it('should intercept when navigating to a multi-param path', async () => {
|
|
const browser = await next.browser('/templates/multi/slug')
|
|
await browser.elementByCss("[href='/showcase/another/slug']").click()
|
|
await browser.waitForElementByCss('#intercepting-page')
|
|
})
|
|
})
|
|
|
|
describe('single param catch-all', () => {
|
|
it('should intercept when navigating to a multi-param path', async () => {
|
|
const browser = await next.browser('/templates/single')
|
|
await browser.elementByCss("[href='/showcase/another/slug']").click()
|
|
await browser.waitForElementByCss('#intercepting-page')
|
|
})
|
|
|
|
it('should intercept when navigating to a single param path', async () => {
|
|
const browser = await next.browser('/templates/single')
|
|
await browser.elementByCss("[href='/showcase/single']").click()
|
|
await browser.waitForElementByCss('#intercepting-page')
|
|
})
|
|
})
|
|
})
|