diff --git a/.changeset/cuddly-snails-boil.md b/.changeset/cuddly-snails-boil.md new file mode 100644 index 000000000..131425136 --- /dev/null +++ b/.changeset/cuddly-snails-boil.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Fix incorrect build path logging for 404.astro pages. diff --git a/packages/astro/src/core/util.ts b/packages/astro/src/core/util.ts index e27348dcb..c3f537243 100644 --- a/packages/astro/src/core/util.ts +++ b/packages/astro/src/core/util.ts @@ -36,7 +36,7 @@ export function padMultilineString(source: string, n = 2) { return lines.map((l) => ` `.repeat(n) + l).join(`\n`); } -const REGEXP_404_OR_500_ROUTE = /(404)|(500)\/?$/; +const STATUS_CODE_PAGES = new Set(['/404', '/500']); /** * Get the correct output filename for a route, based on your config. @@ -50,7 +50,7 @@ export function getOutputFilename(astroConfig: AstroConfig, name: string, type: if (name === '/' || name === '') { return path.posix.join(name, 'index.html'); } - if (astroConfig.build.format === 'file' || REGEXP_404_OR_500_ROUTE.test(name)) { + if (astroConfig.build.format === 'file' || STATUS_CODE_PAGES.has(name)) { return `${removeTrailingForwardSlash(name || 'index')}.html`; } return path.posix.join(name, 'index.html');