From 9e22038472c8be05ed7a72620534b88324dce793 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Alves?= <71379045+andremralves@users.noreply.github.com> Date: Tue, 1 Aug 2023 04:53:47 -0300 Subject: [PATCH] Fix incorrect build path logging for 404.astro pages (#7885) Co-authored-by: Nate Moore --- .changeset/cuddly-snails-boil.md | 5 +++++ packages/astro/src/core/util.ts | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 .changeset/cuddly-snails-boil.md 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');