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

[Bug]: generatePath removes a parameter if it's value is 0 (number) #10593

Closed
Shaddix opened this issue Jun 13, 2023 · 4 comments · Fixed by #10612
Closed

[Bug]: generatePath removes a parameter if it's value is 0 (number) #10593

Shaddix opened this issue Jun 13, 2023 · 4 comments · Fixed by #10612
Labels

Comments

@Shaddix
Copy link

Shaddix commented Jun 13, 2023

What version of React Router are you using?

6.12.1

Steps to Reproduce

generatePath('/product/:id', { id: 0 }) returns /products (expected: /products/0)

I know it's kinda not valid to pass 0 as a number, BUT it worked in 6.3.0 and before (so it's a regression). Also passing any other number works ok:
generatePath('/product/:id', { id: 1 }) returns /products/1
generatePath('/product/:id', { id: 2 }) returns /products/2
of course, passing 0 as string works as well
generatePath('/product/:id', { id: '0' }) returns /products/0

The fact that it works for other numbers could cause issues, because developers might use it, and then suddenly when the value is 0 it stops to work.

Expected Behavior

generatePath('/product/:id', { id: 0 }) -> /products/0

Actual Behavior

generatePath('/product/:id', { id: 0 }) -> /products

@brophdawg11
Copy link
Contributor

Fixed by #10612 and will be included in the next release

@brophdawg11 brophdawg11 added the awaiting release This issue have been fixed and will be released soon label Jun 15, 2023
@github-actions
Copy link
Contributor

🤖 Hello there,

We just published version 6.14.0-pre.0 which involves this issue. If you'd like to take it for a test run please try it out and let us know what you think!

Thanks!

@Shaddix
Copy link
Author

Shaddix commented Jun 21, 2023

thanks, it works

@github-actions
Copy link
Contributor

🤖 Hello there,

We just published version 6.14.0 which involves this issue. If you'd like to take it for a test run please try it out and let us know what you think!

Thanks!

@brophdawg11 brophdawg11 removed the awaiting release This issue have been fixed and will be released soon label Aug 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants