diff --git a/src/history/html5.js b/src/history/html5.js index 9af347fe8..faaa02fcd 100644 --- a/src/history/html5.js +++ b/src/history/html5.js @@ -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