Skip to content

Commit

Permalink
Fix incorrect build path logging for 404.astro pages (#7885)
Browse files Browse the repository at this point in the history
Co-authored-by: Nate Moore <[email protected]>
  • Loading branch information
andremralves and natemoo-re authored Aug 1, 2023
1 parent bd8a01a commit 9e22038
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/cuddly-snails-boil.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

Fix incorrect build path logging for 404.astro pages.
4 changes: 2 additions & 2 deletions packages/astro/src/core/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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');
Expand Down

0 comments on commit 9e22038

Please sign in to comment.