Skip to content

Commit

Permalink
fix(history): stricter check of base in HTML5 (#3556)
Browse files Browse the repository at this point in the history
Co-authored-by: Eduardo San Martin Morote <posva@users.noreply.github.com>
  • Loading branch information
eyedean and posva committed May 31, 2021
1 parent 56f750b commit 11dd184
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/history/html5.js
Expand Up @@ -87,7 +87,13 @@ export class HTML5History extends History {

export function getLocation (base: string): string {
let path = window.location.pathname
if (base && path.toLowerCase().indexOf(base.toLowerCase()) === 0) {
const pathLowerCase = path.toLowerCase()
const baseLowerCase = base.toLowerCase()
// base="/a" shouldn't turn path="/app" into "/a/pp"
// https://github.com/vuejs/vue-router/issues/3555
// so we ensure the trailing slash in the base
if (base && ((pathLowerCase === baseLowerCase) ||
(pathLowerCase.indexOf(cleanPath(baseLowerCase + '/')) === 0))) {
path = path.slice(base.length)
}
return (path || '/') + window.location.search + window.location.hash
Expand Down

0 comments on commit 11dd184

Please sign in to comment.