From 6e659a4267a295a496f82c5e579f5761936fbeda Mon Sep 17 00:00:00 2001 From: fnlctrl Date: Wed, 19 Apr 2017 03:35:52 +0800 Subject: [PATCH 1/2] fix issues of using `base` option with hash --- src/history/html5.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/history/html5.js b/src/history/html5.js index 55df57fbd..2fab0e26c 100644 --- a/src/history/html5.js +++ b/src/history/html5.js @@ -61,6 +61,16 @@ export class HTML5History extends History { export function getLocation (base: string): string { let path = window.location.pathname + + // Special handling for cases where base contains hash ('#') + if (base && base.indexOf('#') > -1) { + path = window.location.href + if (path.indexOf(base) === 0) { + // Leave the rest of the url as-is + return (path.slice(base.length) || '/') + } + } + if (base && path.indexOf(base) === 0) { path = path.slice(base.length) } From b9e8e2b8f13f7046f8f0046ce0bf750d6295c511 Mon Sep 17 00:00:00 2001 From: fnlctrl Date: Wed, 19 Apr 2017 23:42:56 +0800 Subject: [PATCH 2/2] minor fix --- src/history/html5.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/history/html5.js b/src/history/html5.js index 2fab0e26c..914b32ae9 100644 --- a/src/history/html5.js +++ b/src/history/html5.js @@ -64,7 +64,7 @@ export function getLocation (base: string): string { // Special handling for cases where base contains hash ('#') if (base && base.indexOf('#') > -1) { - path = window.location.href + path = window.location.href.replace(window.location.origin, '') if (path.indexOf(base) === 0) { // Leave the rest of the url as-is return (path.slice(base.length) || '/')