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

fix(utils): respect patterns within paths when sorting routes #20669

Merged
merged 31 commits into from May 22, 2023

Conversation

marcelobotega
Copy link

πŸ”— Linked issue

Fixes #10630

❓ Type of change

  • πŸ“– Documentation (updates to the documentation, readme or JSdoc annotations)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

Update sortRoutes to handle routes with letters and * (test*)
Resolves #10630

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@codesandbox
Copy link

codesandbox bot commented May 4, 2023

CodeSandbox logoCodeSandbox logoΒ  Open in CodeSandbox Web Editor | VS Code | VS Code Insiders

# Conflicts:
#	packages/utils/test/__snapshots__/route.test.js.snap
#	yarn.lock
@marcelobotega marcelobotega marked this pull request as ready for review May 4, 2023 10:03
@danielroe danielroe added the 2.x label May 4, 2023
package.json Outdated Show resolved Hide resolved
Make the / optional and match : or * anywhere in the string. This ensures that special routes will be below normal routes. Also ensures that route / will be sorted before the special routes.
@marcelobotega
Copy link
Author

@danielroe can we run the actions on this PR ?

@marcelobotega
Copy link
Author

@danielroe we got an error on the windows audit, how can we fix that ? It's a timeout error.

rchl
rchl previously approved these changes May 17, 2023
Copy link

@rchl rchl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've tested this on a couple of projects that (admittedly) only have a single * route but I haven't noticed any issues.

One thing that happens consistently is that the root route (/) changes position to after all other dynamic routes (ones that use :). So in theory that could result in slightly slower resolving of that particular route but not sure if it's something to be concerned about.

So thumbs up from me.

packages/utils/src/route.js Outdated Show resolved Hide resolved
Co-authored-by: RafaΕ‚ ChΕ‚odnicki <rchl2k@gmail.com>
@marcelobotega marcelobotega requested a review from rchl May 17, 2023 13:58
rchl
rchl previously approved these changes May 17, 2023
@danielroe danielroe added the bug label May 19, 2023
@danielroe danielroe merged commit 5e9942b into nuxt:2.x May 22, 2023
13 checks passed
@danielroe danielroe changed the title fix(utils): update sortRoutes to sort * with letters fix(utils): respect patterns within paths when sorting routes May 22, 2023
@danielroe danielroe mentioned this pull request Jun 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants