Files
504a52aa1f Fixed interception on a catch-all route (#72902)
## For Contributors
### Fixing a bug

Fixes #72523 
Related to b914ad8
Related 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 in b914ad8 added 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]>
2024-11-27 14:30:49 -08:00

17 lines
388 B
TypeScript

import Link from 'next/link'
import React from 'react'
async function Page({ params }: { params: Promise<{ catchAll: string[] }> }) {
const { catchAll } = await params
return (
<div className="text-lg">
Showcase Simple Page
<Link href={`/templates/${catchAll.join('/')}`}>
templates {catchAll.join(' -> ')}
</Link>
</div>
)
}
export default Page