Skip to content

Commit b3523ea

Browse files
committed
[Docs site] Flag unslashed source urls in redirects
1 parent e7a514b commit b3523ea

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

bin/validate-redirects.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ async function main() {
66
let numInfiniteRedirects = 0;
77
let numUrlsWithFragment = 0;
88
let numDuplicateRedirects = 0;
9+
let numNonSlashedRedirects = 0;
910

1011
const redirectSourceUrls: string[] = [];
1112

@@ -24,6 +25,11 @@ async function main() {
2425
numUrlsWithFragment++;
2526
}
2627

28+
if (!from.endsWith("/")) {
29+
console.log(`✘ Found unslashed source URLs:\n ${from}`);
30+
numNonSlashedRedirects++;
31+
}
32+
2733
if (redirectSourceUrls.includes(from)) {
2834
console.log(`✘ Found repeated source URL:\n ${from}`);
2935
numDuplicateRedirects++;
@@ -32,7 +38,12 @@ async function main() {
3238
}
3339
}
3440

35-
if (numInfiniteRedirects || numUrlsWithFragment || numDuplicateRedirects) {
41+
if (
42+
numInfiniteRedirects ||
43+
numUrlsWithFragment ||
44+
numDuplicateRedirects ||
45+
numNonSlashedRedirects
46+
) {
3647
console.log("\nDetected errors:");
3748

3849
if (numInfiniteRedirects > 0) {
@@ -47,6 +58,12 @@ async function main() {
4758
console.log(`- ${numDuplicateRedirects} repeated source URL(s)`);
4859
}
4960

61+
if (numNonSlashedRedirects > 0) {
62+
console.log(
63+
`- ${numNonSlashedRedirects} need slashes at the end of the source URL`,
64+
);
65+
}
66+
5067
console.log("\nPlease fix the errors above before merging :)");
5168
process.exit(1);
5269
} else {

0 commit comments

Comments
 (0)