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

Explicit prefix and suffix modifiers #306

Merged
merged 4 commits into from
Jun 20, 2024
Merged

Conversation

blakeembrey
Copy link
Member

Demo using explicit {} for prefix/suffix instead of implicit / and ., and nothing in other positions. This would allow for much clearer error and edge case handling of things like -:path* which is meaningless today, while /:path* is actually useful. It more closely aligns behavior with some other path matching libraries, such as Rails which uses () to denotes optional.

However, it does break compatibility as a result of fixing these quirks. As part of this PR there is a good attempt at ensuring the upgrade path is pretty easy, and it gives clear errors with a link and the exact part of the string where the error occurred. Mostly it'll be /:path? to {/:path}?. I've also disallowed /:path* which could be confused as * is now a wildcard, and writing that path is probably a bug. As a result, this does give a simple library upgrade path that adds back /:path?, /:path+, /:path* if needed by users.

It's also fairly easy to write a path rewrite script that'll update the syntax if people want it, both for Express.js 4.x and the current major release.

@blakeembrey blakeembrey merged commit 8b74404 into master Jun 20, 2024
4 checks passed
@blakeembrey blakeembrey deleted the be/modifier-prefix-suffix branch June 20, 2024 22:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant