Skip to content

website - improve warning when alias redirection would overwrite file #12551

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions src/project/types/website/website-aliases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading