diff --git a/src/core/router/history/hash.js b/src/core/router/history/hash.js index caaea4571..847445400 100644 --- a/src/core/router/history/hash.js +++ b/src/core/router/history/hash.js @@ -18,7 +18,10 @@ export class HashHistory extends History { const path = window.location.pathname || ''; const base = this.config.basePath; - return /^(\/|https?:)/g.test(base) ? base : cleanPath(path + '/' + base); + const basePath = path.endsWith('.html') + ? path + '#/' + base + : path + '/' + base; + return /^(\/|https?:)/g.test(base) ? base : cleanPath(basePath); } getCurrentPath() { diff --git a/src/core/router/util.js b/src/core/router/util.js index fc3e2f79d..c26b8d06c 100644 --- a/src/core/router/util.js +++ b/src/core/router/util.js @@ -76,8 +76,15 @@ export const resolvePath = cached(path => { return '/' + resolved.join('/'); }); +function normaliseFragment(path) { + return path + .split('/') + .filter(p => !p.includes('#')) + .join('/'); +} + export function getPath(...args) { - return cleanPath(args.join('/')); + return cleanPath(args.map(normaliseFragment).join('/')); } export const replaceSlug = cached(path => {