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 {
11
11
let self = this
12
12
this . listener = function ( ) {
13
13
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 )
15
20
if ( formattedPath !== path ) {
16
21
location . replace ( formattedPath )
17
22
return
@@ -38,14 +43,10 @@ export default class HashHistory {
38
43
}
39
44
}
40
45
41
- formatPath ( path , expectAbsolute ) {
42
- path = path . replace ( / ^ # ! ? / , '' )
46
+ formatPath ( path ) {
43
47
let isAbsoloute = path . charAt ( 0 ) === '/'
44
- if ( expectAbsolute && ! isAbsoloute ) {
45
- path = '/' + path
46
- }
47
48
let prefix = '#' + ( this . hashbang ? '!' : '' )
48
- return isAbsoloute || expectAbsolute
49
+ return isAbsoloute
49
50
? prefix + path
50
51
: prefix + resolvePath (
51
52
location . hash . replace ( / ^ # ! ? / , '' ) ,
You can’t perform that action at this time.
0 commit comments