Skip to content

Commit f5db5b8

Browse files
fnlctrlyyx990803
authored andcommitted
Allow using base option with hash under history mode (vuejs#1349)
* fix issues of using `base` option with hash * minor fix
1 parent 52f4a9a commit f5db5b8

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/history/html5.js

+10
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,16 @@ export class HTML5History extends History {
6262

6363
export function getLocation (base: string): string {
6464
let path = window.location.pathname
65+
66+
// Special handling for cases where base contains hash ('#')
67+
if (base && base.indexOf('#') > -1) {
68+
path = window.location.href.replace(window.location.origin, '')
69+
if (path.indexOf(base) === 0) {
70+
// Leave the rest of the url as-is
71+
return (path.slice(base.length) || '/')
72+
}
73+
}
74+
6575
if (base && path.indexOf(base) === 0) {
6676
path = path.slice(base.length)
6777
}

0 commit comments

Comments
 (0)