Skip to content

href() builder produces invalid URL on optional segments #13055

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

Closed
cloudkite opened this issue Feb 19, 2025 · 4 comments · Fixed by #13595
Closed

href() builder produces invalid URL on optional segments #13055

cloudkite opened this issue Feb 19, 2025 · 4 comments · Fixed by #13595

Comments

@cloudkite
Copy link

cloudkite commented Feb 19, 2025

I'm using React Router as a...

Framework

Reproduction

Given that i have a route in routes.ts as :

    route(
      "task/:taskId/v?/:versionId?",
      "task.route.tsx",
    ),

System Info

react-router v7.2

Used Package Manager

npm

Expected Behavior

href("task/:taskId/v?/:versionId?", { taskId: "123" }) === "task/123"
href("task/:taskId/v?/:versionId?", { taskId: "123", versionId: "hello" }) === "task/123/v/hello"

Actual Behavior

href("task/:taskId/v?/:versionId?", { taskId: "123" }) === "task/123/v?"
href("task/:taskId/v?/:versionId?", { taskId: "123", versionId: "hello" }) === "task/123/v?/hello"

@cloudkite cloudkite added the bug label Feb 19, 2025
@cloudkite cloudkite changed the title new href builder produces invalid URL on optional segments href() builder produces invalid URL on optional segments Feb 19, 2025
@pcattori pcattori self-assigned this Feb 19, 2025
@eugeniobet

This comment has been minimized.

@martinliptak
Copy link

martinliptak commented Mar 27, 2025

Also came across this problem - seems like a bug.

@pcattori pcattori linked a pull request May 12, 2025 that will close this issue
2 tasks
@pcattori
Copy link
Contributor

Fixed by #13595 , which should be available next release

Copy link
Contributor

🤖 Hello there,

We just published version 7.6.1 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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants