Skip to content

Commit e877e7a

Browse files
committed
fix: handle query parameters in getFileName method
1 parent 8c545d1 commit e877e7a

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

src/core/router/history/base.js

+13-7
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import {
2+
cleanPath,
23
getPath,
34
isAbsolutePath,
4-
stringifyQuery,
5-
cleanPath,
65
replaceSlug,
76
resolvePath,
7+
stringifyQuery,
88
} from '../util.js';
99
import { noop } from '../../util/core.js';
1010

@@ -32,11 +32,17 @@ export class History {
3232
}
3333

3434
#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;
4046
}
4147

4248
getBasePath() {

0 commit comments

Comments
 (0)