Skip to content

Commit 11dd184

Browse files
eyedeanposva
andauthored
fix(history): stricter check of base in HTML5 (#3556)
Co-authored-by: Eduardo San Martin Morote <[email protected]>
1 parent 56f750b commit 11dd184

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/history/html5.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,13 @@ export class HTML5History extends History {
8787

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

0 commit comments

Comments
 (0)