Skip to content

fix: allow relative paths with colons without ./ prefix#14714

Closed
0372hoanghoccode wants to merge 2 commits intoremix-run:devfrom
0372hoanghoccode:fix/colon-in-relative-paths-14711
Closed

fix: allow relative paths with colons without ./ prefix#14714
0372hoanghoccode wants to merge 2 commits intoremix-run:devfrom
0372hoanghoccode:fix/colon-in-relative-paths-14711

Conversation

@0372hoanghoccode
Copy link

Fixes regression in v7.9.6 where paths like 'my-path:value' were incorrectly treated as absolute URLs. Now only hierarchical URLs (scheme://) and protocol-relative URLs (//) are treated as absolute, allowing relative paths with colons to work as expected.

Fixes #14711

@changeset-bot
Copy link

changeset-bot bot commented Jan 8, 2026

🦋 Changeset detected

Latest commit: 580875f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 11 packages
Name Type
react-router Patch
react-router-dom Patch
@react-router/dev Patch
@react-router/cloudflare Patch
@react-router/node Patch
@react-router/serve Patch
@react-router/fs-routes Patch
@react-router/express Patch
@react-router/architect Patch
@react-router/remix-routes-option-adapter Patch
create-react-router Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@remix-cla-bot
Copy link
Contributor

remix-cla-bot bot commented Jan 8, 2026

Hi @0372hoanghoccode,

Welcome, and thank you for contributing to React Router!

Before we consider your pull request, we ask that you sign our Contributor License Agreement (CLA). We require this only once.

You may review the CLA and sign it by adding your name to contributors.yml.

Once the CLA is signed, the CLA Signed label will be added to the pull request.

If you have already signed the CLA and received this response in error, or if you have any questions, please contact us at hello@remix.run.

Thanks!

- The Remix team

@remix-cla-bot
Copy link
Contributor

remix-cla-bot bot commented Jan 8, 2026

Thank you for signing the Contributor License Agreement. Let's get this merged! 🥳

@brophdawg11 brophdawg11 self-assigned this Jan 8, 2026
@brophdawg11 brophdawg11 self-requested a review January 8, 2026 14:28
@brophdawg11 brophdawg11 removed their assignment Jan 8, 2026
@0372hoanghoccode
Copy link
Author

Done! I've updated the \isAbsoluteUrl\ function to use the more specific regex and removed the inline regex from
esolvePath(). This avoids recompiling the regex on every call. Thank you for the feedback and for taking the time to review!

Fixes remix-run#14711

Updated ABSOLUTE_URL_REGEX to only match:
- Hierarchical URLs (scheme://)
- Protocol-relative URLs (//)
- Common non-hierarchical schemes (mailto:, tel:, etc.)

This allows paths like 'my-path:with-colon' to be resolved as relative
paths without requiring a ./ prefix, while still preserving support for
actual absolute URLs like mailto:, tel:, data:, etc.

The regex is defined in isAbsoluteUrl() to avoid recompiling on every
resolvePath() call.
@0372hoanghoccode 0372hoanghoccode force-pushed the fix/colon-in-relative-paths-14711 branch from 8822656 to 5a3a044 Compare January 8, 2026 17:33
@0372hoanghoccode
Copy link
Author

Updated the implementation after additional testing revealed that the previous regex broke support for non-hierarchical URL schemes like mailto:, tel:, etc.

The new regex now:

  • Matches hierarchical URLs (scheme://)
  • Matches protocol-relative URLs (//)
  • Matches common non-hierarchical schemes (mailto:, tel:, sms, data, blob, file, app, chrome-extension, etc.)
  • Allows relative paths with colons (my-path:with-colon, item:123)

The regex is defined once in isAbsoluteUrl() to avoid recompiling on every resolvePath() call, as you suggested.

All 862 router tests pass including the SSR tests that verify mailto: and other schemes work correctly.

@0372hoanghoccode 0372hoanghoccode force-pushed the fix/colon-in-relative-paths-14711 branch from 5a3a044 to 580875f Compare January 8, 2026 17:56
@brophdawg11
Copy link
Contributor

Thank you for the PR - but I don't think we want to change our detection to include a list of acceptable protocols. I think the real bug here is that we shouldn't have bypassed resolvePathname for absolute URLs since resolvePath should only be relevant for pathnames and not absolute URLs. Closing this in favor of #14718

@brophdawg11 brophdawg11 closed this Jan 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants