Fix incorrect build path logging for 404.astro pages (#7885)

Co-authored-by: Nate Moore <natemoo-re@users.noreply.github.com>
This commit is contained in:
André Alves 2023-08-01 04:53:47 -03:00 committed by GitHub
parent bd8a01ae1b
commit 9e22038472
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View file

@ -0,0 +1,5 @@
---
'astro': patch
---
Fix incorrect build path logging for 404.astro pages.

View file

@ -36,7 +36,7 @@ export function padMultilineString(source: string, n = 2) {
return lines.map((l) => ` `.repeat(n) + l).join(`\n`); 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. * 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 === '') { if (name === '/' || name === '') {
return path.posix.join(name, 'index.html'); 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 `${removeTrailingForwardSlash(name || 'index')}.html`;
} }
return path.posix.join(name, 'index.html'); return path.posix.join(name, 'index.html');