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

fix(history): stricter check of base in HTML5 #3556

Merged
merged 7 commits into from
May 31, 2021
Merged

fix(history): stricter check of base in HTML5 #3556

merged 7 commits into from
May 31, 2021

Conversation

eyedean
Copy link
Contributor

@eyedean eyedean commented May 20, 2021

Fixed a bug in getLocation of HTML5 History that would slice the path, even if it's just a string-prefix of the base. (e.g. for base=/a/ and path=/app it would turn it to /a/pp.)

With the fix, I replaced the string-prefix check (via path.indexOf(base) === 0) into, an OR of these two conditions:

  • Either path === base (case insensitive, as it was)
  • Or, the path starts with base as a directory (i.e. base plus at least a / after that), so path.indexOf(base+"/") === 0

I tested it locally in my own repo that had this problem, and the fix is effective. I also ran the npm test and it passed all the tests. I didn't find any example unit test is already testing custom base to add to it.

Thanks.

Fix #3555

@posva posva changed the title fix #3555: fix(html5): initial path in HTML5 vs base (#3555) fix(html5): initial path in HTML5 vs base May 29, 2021
@posva posva changed the title fix(html5): initial path in HTML5 vs base fix(history): stricter check of base in HTML5 May 29, 2021
Copy link
Member

@posva posva left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

src/history/html5.js Show resolved Hide resolved
src/history/html5.js Outdated Show resolved Hide resolved
Copy link
Member

@posva posva left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@posva posva merged commit 11dd184 into vuejs:dev May 31, 2021
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.

With routerBase being "/a/", landing on "/app" is incorrectly redirected to "/a/pp"
2 participants