Skip to content

Commit

Permalink
fix: handle query parameters in getFileName method
Browse files Browse the repository at this point in the history
  • Loading branch information
sy-records committed Jan 14, 2025
1 parent 24d2671 commit fc4e3be
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/core/router/history/base.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {
cleanPath,
getPath,
isAbsolutePath,
stringifyQuery,
cleanPath,
replaceSlug,
resolvePath,
stringifyQuery,
} from '../util.js';
import { noop } from '../../util/core.js';

Expand Down Expand Up @@ -32,11 +32,17 @@ export class History {
}

#getFileName(path, ext) {
return new RegExp(`\\.(${ext.replace(/^\./, '')}|html)$`, 'g').test(path)
? path
: /\/$/g.test(path)
? `${path}README${ext}`
: `${path}${ext}`;
const [basePath, query] = path.split("?");

const hasValidExt = new RegExp(`\\.(${ext.replace(/^\./, '')}|html)$`, 'g').test(basePath);

const updatedPath = hasValidExt
? basePath
: /\/$/g.test(basePath)
? `${basePath}README${ext}`
: `${basePath}${ext}`;

return query ? `${updatedPath}?${query}` : updatedPath;
}

getBasePath() {
Expand Down

0 comments on commit fc4e3be

Please sign in to comment.