diff options
author | 2024-12-11 11:06:55 +0000 | |
---|---|---|
committer | 2024-12-11 11:06:55 +0000 | |
commit | 99266fa2898289a172d70a5ac3ffad7a5dcd2867 (patch) | |
tree | 99bc95d1bcb7c314eb7cef59d00d98fe46435840 | |
parent | d33c2151a37e71ba727c54ef30339df859148612 (diff) | |
download | astro-99266fa2898289a172d70a5ac3ffad7a5dcd2867.tar.gz astro-99266fa2898289a172d70a5ac3ffad7a5dcd2867.tar.zst astro-99266fa2898289a172d70a5ac3ffad7a5dcd2867.zip |
chore: refactor query param strip (#12714)
-rw-r--r-- | packages/astro/src/core/util.ts | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/packages/astro/src/core/util.ts b/packages/astro/src/core/util.ts index 88e1de81a..3a394764b 100644 --- a/packages/astro/src/core/util.ts +++ b/packages/astro/src/core/util.ts @@ -5,7 +5,7 @@ import type { AstroSettings } from '../types/astro.js'; import type { AstroConfig } from '../types/public/config.js'; import type { RouteType } from '../types/public/internal.js'; import { SUPPORTED_MARKDOWN_FILE_EXTENSIONS } from './constants.js'; -import { removeTrailingForwardSlash, slash } from './path.js'; +import { removeTrailingForwardSlash, slash, removeQueryString } from './path.js'; /** Returns true if argument is an object of any prototype/class (but not null). */ export function isObject(value: unknown): value is Record<string, any> { @@ -18,8 +18,7 @@ export function isURL(value: unknown): value is URL { } /** Check if a file is a markdown file based on its extension */ export function isMarkdownFile(fileId: string, option?: { suffix?: string }): boolean { - // Strip query string - const id = fileId.split('?')[0]; + const id = removeQueryString(fileId); const _suffix = option?.suffix ?? ''; for (let markdownFileExtension of SUPPORTED_MARKDOWN_FILE_EXTENSIONS) { if (id.endsWith(`${markdownFileExtension}${_suffix}`)) return true; |