Skip to content

fix: Remove unwanted trailing slash when resolving href in hash mode #36

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tanishq-aggarwal
Copy link

In hash mode, resolveNewHref() adds a trailing slash to the URL's pathname to avoid ambiguity between path segments and query strings like this:
chrome-extension://<ext_id>/popup.html/#/settings-page
But in Chrome extensions—where resources like popup.html live under the chrome-extension:// protocol—a trailing slash in the pathname causes Chrome to treat it as a request for a directory rather than a file, when the user inputs this URL directly in their address bar. This shows them a "Your file couldn't be accessed" error.

We need to instead resolve it to this:
chrome-extension://<ext_id>/popup.html#/settings-page
When a user directly inputs this in their address bar, the browser correctly opens the popup.html file and the router correctly routes us to the /settings-page as expected.

In browser extension environments, when using hash mode, resolveNewHref() was appending a trailing slash which gives a "Youre file couldn't be accessed" error when the user directly enters that href in the url bar.

Removing the trailing slash fixes that issue.
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.

1 participant