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

Removing basename results in empty location.pathname #483

Open
catamphetamine opened this issue Nov 19, 2023 · 0 comments
Open

Removing basename results in empty location.pathname #483

catamphetamine opened this issue Nov 19, 2023 · 0 comments

Comments

@catamphetamine
Copy link

location.pathname is supposed to always be non-empty.

If basename is set to /basename and the user navigates to /basename URL, createBasenameMiddleware() simply strips the whole string from the URL and the result is incorrect: pathname: "".

The fix would be adding || '/' after location.pathname.slice(pathnamePrefix.length):

    makeLocation: (location) => ({
      ...location,
      pathname:
        location.pathname.indexOf(pathnamePrefix) === 0
          ? location.pathname.slice(pathnamePrefix.length)
          : null,
    }),
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

No branches or pull requests

1 participant