File tree 1 file changed +13
-7
lines changed
1 file changed +13
-7
lines changed Original file line number Diff line number Diff line change 1
1
import {
2
+ cleanPath ,
2
3
getPath ,
3
4
isAbsolutePath ,
4
- stringifyQuery ,
5
- cleanPath ,
6
5
replaceSlug ,
7
6
resolvePath ,
7
+ stringifyQuery ,
8
8
} from '../util.js' ;
9
9
import { noop } from '../../util/core.js' ;
10
10
@@ -32,11 +32,17 @@ export class History {
32
32
}
33
33
34
34
#getFileName( path , ext ) {
35
- return new RegExp ( `\\.(${ ext . replace ( / ^ \. / , '' ) } |html)$` , 'g' ) . test ( path )
36
- ? path
37
- : / \/ $ / g. test ( path )
38
- ? `${ path } README${ ext } `
39
- : `${ path } ${ ext } ` ;
35
+ const [ basePath , query ] = path . split ( "?" ) ;
36
+
37
+ const hasValidExt = new RegExp ( `\\.(${ ext . replace ( / ^ \. / , '' ) } |html)$` , 'g' ) . test ( basePath ) ;
38
+
39
+ const updatedPath = hasValidExt
40
+ ? basePath
41
+ : / \/ $ / g. test ( basePath )
42
+ ? `${ basePath } README${ ext } `
43
+ : `${ basePath } ${ ext } ` ;
44
+
45
+ return query ? `${ updatedPath } ?${ query } ` : updatedPath ;
40
46
}
41
47
42
48
getBasePath ( ) {
You can’t perform that action at this time.
0 commit comments