Skip to content

Commit 0c238c4

Browse files
Fix hash mode deep links
1 parent 65b2f45 commit 0c238c4

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

Diff for: src/history/hash.js

+9-6
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ import { setupScroll, handleScroll } from '../util/scroll'
88
import { pushState, replaceState, supportsPushState } from '../util/push-state'
99

1010
export class HashHistory extends History {
11-
constructor (router: Router, base: ?string, fallback: boolean) {
11+
constructor (router: Router, base: ?string) {
1212
super(router, base)
1313
// check history fallback deeplinking
14-
if (fallback && checkFallback(this.base)) {
14+
if (checkFallback(this.base)) {
1515
return
1616
}
1717
ensureSlash()
@@ -80,10 +80,13 @@ export class HashHistory extends History {
8080

8181
function checkFallback (base) {
8282
const location = getLocation(base)
83-
if (!/^\/#/.test(location)) {
84-
window.location.replace(
85-
cleanPath(base + '/#' + location)
86-
)
83+
if (location !== '/' && !/^\/#/.test(location)) {
84+
const path = cleanPath(base + '/#' + location)
85+
if (supportsPushState) {
86+
replaceState(path)
87+
} else {
88+
window.location.replace(path)
89+
}
8790
return true
8891
}
8992
}

Diff for: src/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export default class VueRouter {
5656
this.history = new HTML5History(this, options.base)
5757
break
5858
case 'hash':
59-
this.history = new HashHistory(this, options.base, this.fallback)
59+
this.history = new HashHistory(this, options.base)
6060
break
6161
case 'abstract':
6262
this.history = new AbstractHistory(this, options.base)

0 commit comments

Comments
 (0)