Skip to content

Commit bc4dfd6

Browse files
committed
properly handle query string in both original url and the hash fragment (fix #243)
1 parent c955be3 commit bc4dfd6

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/history/hash.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,13 @@ export default class HashHistory {
2121
location.replace(formattedPath)
2222
return
2323
}
24-
let pathToMatch = decodeURI(
25-
path.replace(/^#!?/, '') + location.search
26-
)
27-
self.onChange(pathToMatch)
24+
// determine query
25+
// note it's possible to have queries in both the actual URL
26+
// and the hash fragment itself.
27+
let query = location.search && path.indexOf('?') > -1
28+
? '&' + location.search.slice(1)
29+
: location.search
30+
self.onChange(decodeURI(path.replace(/^#!?/, '') + query))
2831
}
2932
window.addEventListener('hashchange', this.listener)
3033
this.listener()

0 commit comments

Comments
 (0)