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

feat!: support mixed params in same path segment #52

Merged
merged 3 commits into from
Oct 4, 2023

Conversation

pi0
Copy link
Member

@pi0 pi0 commented Apr 21, 2023

Resolves #11
Resolves #42

This feature allows to combine more advanced URL patterns such as /files/:category/:id,name:name.txt to be able to mix and match multiple static and dynamic params in same segment (/files/test/123,name=foobar.txt" should match to { category: "test", id: "123", name: "foobar" }).

The breaking change is that param name should be strict a-zA-Z0-9_ only not accepting . in it and : in between anymore.

Also since we introduced new MIXED type, it should be applied if any library like nuxt and nitro was translating patterns to other platforms, to have it in mind that a mixed segment not essentially starting with : but can have it in between.

Implementation also requires String.prototype.matchAll support compatibility. (i am open to adding polyfill in later releases if there was a platform absolutely cannot have it now.

@pi0 pi0 changed the title feat!: support mixed params in same segment feat!: support mixed params in same path segment Apr 21, 2023
@pi0 pi0 marked this pull request as ready for review October 4, 2023 10:00
@codecov
Copy link

codecov bot commented Oct 4, 2023

Codecov Report

Merging #52 (c3aa794) into main (0202d4c) will increase coverage by 0.22%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main      #52      +/-   ##
==========================================
+ Coverage   95.41%   95.63%   +0.22%     
==========================================
  Files           4        4              
  Lines         414      435      +21     
  Branches       75       83       +8     
==========================================
+ Hits          395      416      +21     
  Misses         19       19              
Files Coverage Δ
src/router.ts 100.00% <100.00%> (ø)
src/types.ts 100.00% <100.00%> (ø)

@pi0 pi0 merged commit 130c4b8 into main Oct 4, 2023
3 checks passed
@pi0 pi0 deleted the feat/combined-static-dynamic branch October 4, 2023 15:36
@pi0 pi0 mentioned this pull request Oct 5, 2023
@manniL manniL mentioned this pull request Dec 26, 2023
4 tasks
@pi0 pi0 mentioned this pull request Mar 8, 2024
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.

Radix node with multiple parameters Support mixing dynamic params with static string in same segment
1 participant