From 67e4c3b560cd0749be1b101be8b5157f5b1e1184 Mon Sep 17 00:00:00 2001 From: Carlos Scheidegger Date: Tue, 15 Apr 2025 15:23:31 -0400 Subject: [PATCH] website - improve warning when alias redirection would overwrite file --- src/project/types/website/website-aliases.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/project/types/website/website-aliases.ts b/src/project/types/website/website-aliases.ts index 9a6b9565353..6ea92b1dc22 100644 --- a/src/project/types/website/website-aliases.ts +++ b/src/project/types/website/website-aliases.ts @@ -106,10 +106,17 @@ export async function updateAliases( // Write the redirect file if (allOutputFiles.find((outputFile) => outputFile === targetFile)) { - // Do not, this is the same name as an output file! - warning( - `Aliases that you have created would overwrite the output file ${targetFile}. The aliases file was not created.`, - ); + for ( + const offendingAlias of targetHrefs.filter( + (targetHref) => + targetHref.href === + relative(dirname(targetHref.outputFile), targetFile), + ) + ) { + warning( + `Requested alias ${targetFile} -> ${offendingAlias.outputFile} would overwrite the target. Skipping.`, + ); + } } else { // Write, this is a safe file writeMultipleRedirectPage(targetFile, redirects);