Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Intercepting Routes with Dynamic catch all segments #72523

Open
programming-with-ia opened this issue Nov 8, 2024 · 2 comments · May be fixed by #72902
Open

Intercepting Routes with Dynamic catch all segments #72523

programming-with-ia opened this issue Nov 8, 2024 · 2 comments · May be fixed by #72902
Labels
bug Issue was opened via the bug report template. Developer Experience Issues related to Next.js logs, Error overlay, etc. dynamicIO Related to dynamicIO. Navigation Related to Next.js linking (e.g., <Link>) and navigation. Parallel & Intercepting Routes Related to Parallel and/or Intercepting routes. Performance Anything with regards to Next.js performance.

Comments

@programming-with-ia
Copy link

Link to the code that reproduces this issue

https://github.com/programming-with-ia/intercepting-test

To Reproduce

  1. start using pnpm dev

Working

http://localhost:3001/templates/single -> http://localhost:3001/showcase/single is work
http://localhost:3001/templates/multi/slug -> http://localhost:3001/showcase/single is work

Not Working

http://localhost:3001/templates/multi/slug -> http://localhost:3001/showcase/multi/slug doesn't work (this will show normal page not Intercepting page

Current vs. Expected behavior

when
http://localhost:3001/templates/multi/slug -> http://localhost:3001/showcase/multi/slug show Intercepting page

Provide environment information

Operating System:
  Platform: win32
  Arch: x64
  Version: Windows 11 Pro
  Available memory (MB): 16231
  Available CPU cores: 4
Binaries:
  Node: 20.17.0
  npm: 10.7.0
  Yarn: N/A
  pnpm: 9.8.0
Relevant Packages:
  next: 15.0.3 // Latest available version is detected (15.0.3).
  eslint-config-next: 15.0.3
  react: 18.3.1
  react-dom: 18.3.1
  typescript: 5.6.3
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Developer Experience, dynamicIO, Navigation, Parallel & Intercepting Routes, Performance

Which stage(s) are affected? (Select all that apply)

next build (local), next start (local), Vercel (Deployed), Other (Deployed)

Additional context

No response

@programming-with-ia programming-with-ia added the bug Issue was opened via the bug report template. label Nov 8, 2024
@github-actions github-actions bot added Developer Experience Issues related to Next.js logs, Error overlay, etc. dynamicIO Related to dynamicIO. Navigation Related to Next.js linking (e.g., <Link>) and navigation. Parallel & Intercepting Routes Related to Parallel and/or Intercepting routes. Performance Anything with regards to Next.js performance. labels Nov 8, 2024
@Reflex2468
Copy link

Reflex2468 commented Nov 17, 2024

From testing locally, I see this was fixed by: #51787

But broken again after b914ad8

I'm not sure what the issue was from b914ad8, but locally, after changing the code in toPathToRegexp I was able to solve the issue.

function toPathToRegexpPath(path: string): string {
  return path.replace(/\[\[?([^\]]+)\]\]?/g, (_, capture) => {
    // path-to-regexp only supports word characters, so we replace any non-word characters with underscores
    const paramName = capture.replace(/\W+/g, '_')

    // handle catch-all segments (e.g. /foo/bar/[...baz] or /foo/bar/[[...baz]])
-     if (paramName.startsWith('...')) {
-       return `:${paramName.slice(3)}*`
+    if (capture.startsWith('...')) {
+       return `:${capture.slice(3)}*`
    }
    return ':' + paramName
  })
}

Basically the replace of /\W+/ also replaces the ... with _ so the the if statement two lines below always returns false.

@programming-with-ia
Copy link
Author

Basically the replace of /\W+/ also replaces the ... with _ so the the if statement two lines below always returns false

Nice

@Reflex2468 Reflex2468 linked a pull request Nov 17, 2024 that will close this issue
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue was opened via the bug report template. Developer Experience Issues related to Next.js logs, Error overlay, etc. dynamicIO Related to dynamicIO. Navigation Related to Next.js linking (e.g., <Link>) and navigation. Parallel & Intercepting Routes Related to Parallel and/or Intercepting routes. Performance Anything with regards to Next.js performance.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants