-
-
Notifications
You must be signed in to change notification settings - Fork 10.2k
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]: "Failed to construct 'URL': Invalid URL" error when using lazy loading and double slash in URL #11188
Comments
unfortunately, i have the same problem, is there any solution? |
Looks like a duplicate of #11429 @mskrzypek if it helps I investigated that one slightly. It looks like official URL spec that |
@hjonasson Thank you for your investigation. I believe, this is not a duplicate of #11429. Please refer to the reproduction example, which clearly explains the problem. When we use the Regardless of the URL specification, it is a very popular convention to handle doubled slashes in URLs, and I think it is not uncommon for users to mistakenly enter two slashes instead of one in a URL. If one could perform some benchmarks, it turns out that in most solutions, double slashes are converted to single slashes, e.g. |
What version of React Router are you using?
6.21.2
Steps to Reproduce
Prepare routing with lazy loaded component at root path:
Open app in browser with additional slash at the end of the URL, ie.
http://localhost:3000//
Expected Behavior
Lazy loaded component is rendered at root URL, even though there are two slashes in the URL.
Actual Behavior
Lazy loaded component is not loading, there is
Failed to construct 'URL': Invalid URL
error. When component is rendered withelement
, it is being rendered correctly.I prepared a reproduction example: https://codesandbox.io/p/sandbox/blissful-ritchie-9szrnk
The text was updated successfully, but these errors were encountered: