File tree Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -11,7 +11,12 @@ export default class HashHistory {
1111 let self = this
1212 this . listener = function ( ) {
1313 let path = location . hash
14- let formattedPath = self . formatPath ( path , true )
14+ let raw = path . replace ( / ^ # ! ? / , '' )
15+ // always
16+ if ( raw . charAt ( 0 ) !== '/' ) {
17+ raw = '/' + raw
18+ }
19+ let formattedPath = self . formatPath ( raw )
1520 if ( formattedPath !== path ) {
1621 location . replace ( formattedPath )
1722 return
@@ -38,14 +43,10 @@ export default class HashHistory {
3843 }
3944 }
4045
41- formatPath ( path , expectAbsolute ) {
42- path = path . replace ( / ^ # ! ? / , '' )
46+ formatPath ( path ) {
4347 let isAbsoloute = path . charAt ( 0 ) === '/'
44- if ( expectAbsolute && ! isAbsoloute ) {
45- path = '/' + path
46- }
4748 let prefix = '#' + ( this . hashbang ? '!' : '' )
48- return isAbsoloute || expectAbsolute
49+ return isAbsoloute
4950 ? prefix + path
5051 : prefix + resolvePath (
5152 location . hash . replace ( / ^ # ! ? / , '' ) ,
You can’t perform that action at this time.
0 commit comments