sandulat / routes-gen

Framework agnostic routes typings generator. Remix ☑️ SolidStart ☑️
MIT License
283 stars 12 forks source link

Only replace the first instance of a param replacement string #38

Closed br0p0p closed 1 year ago

br0p0p commented 1 year ago

I encountered an issue where replacing route params doesn't work correctly if the route params share the same prefix.

Actual behavior:

routes('/podcasts/:topic/:topicId', { topic: 'sports', topicId: '123' }) // => '/podcasts/sports/sportsId'

Expected behavior:

routes('/podcasts/:topic/:topicId', { topic: 'sports', topicId: '123' }) // => '/podcasts/sports/123'

This PR refactors the route() function to address this issue and includes tests to ensure existing behavior is not broken.

sandulat commented 1 year ago

@br0p0p Thank you so much for your effort! I really appreciate it! I'm currently on vacation and I'll merge both of your PRs as I'll have some time. Sorry for the delay.

br0p0p commented 1 year ago

@sandulat no problem, enjoy your vacation :)

br0p0p commented 1 year ago

@sandulat any update here?

sandulat commented 1 year ago

@br0p0p This is now published under routes-gen@0.6.1. I sincerely apologise for this enormous delay! I was overwhelmed with a significant amount of work and completely lost track of this. I am very grateful for your efforts!