Skip to content
This repository was archived by the owner on May 10, 2021. It is now read-only.

Fix broken redirects (#45) #47

Merged
merged 4 commits into from
Oct 2, 2020
Merged

Fix broken redirects (#45) #47

merged 4 commits into from
Oct 2, 2020

Conversation

FinnWoelm
Copy link
Contributor

During the refactoring last week, I accidentally introduced two bugs into the redirects generated by next-on-netlify. One bug caused invalid rewrites to be generated when having an optional catch-all route at top-level (e.g., /pages/[[...slug]].js). The other bug caused the rewrites to be in the incorrect order, leading to catch-all routes preceding more specific, static routes.

This fixes #45.

📣 Shoutout to @lindsaylevine for pair-programming and fixing this together! ✨

Use the NextJS code for sorting routes (instead of @sls-next's code):
- /node_modules/next/dist/next-server/lib/router/utils/sorted-routes
- https://github.com/vercel/next.js/blob/canary/packages/next/
  next-server/lib/router/utils/sorted-routes.ts

The regex for removing file endings used in /lib/helpers/getSortedRoutes
was incorrect and led to incorrect route paths being passed into the
sorting function. This has been fixed.
Remove two unused require-statements from
/lib/pages/getStaticProps/redirects.js. These are leftover from
refactoring.
@lindsaylevine lindsaylevine merged commit 23144d4 into main Oct 2, 2020
lindsaylevine added a commit that referenced this pull request Oct 2, 2020
- Fix: broken redirects for optional catch-alls ([#47](#47))
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Broken redirects with optional catch-all route at top-level in pages/
2 participants