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

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

Merged
merged 5 commits into from
Jul 27, 2023
Merged

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

merged 5 commits into from
Jul 27, 2023

Conversation

br0p0p
Copy link
Contributor

@br0p0p br0p0p commented Jun 13, 2023

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
Copy link
Owner

@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
Copy link
Contributor Author

br0p0p commented Jun 15, 2023

@sandulat no problem, enjoy your vacation :)

@br0p0p
Copy link
Contributor Author

br0p0p commented Jul 27, 2023

@sandulat any update here?

@sandulat sandulat merged commit f184d74 into sandulat:main Jul 27, 2023
@sandulat
Copy link
Owner

@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!

@br0p0p br0p0p deleted the replace-first-instance-only branch July 28, 2023 00:17
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.

None yet

2 participants