@@ -6,6 +6,9 @@ async function main() {
6
6
let numInfiniteRedirects = 0 ;
7
7
let numUrlsWithFragment = 0 ;
8
8
let numDuplicateRedirects = 0 ;
9
+ let numNonSlashedRedirects = 0 ;
10
+
11
+ const validEndings = [ "/" , "*" , ".xml" , ".md" , ".json" , ".html" ] ;
9
12
10
13
const redirectSourceUrls : string [ ] = [ ] ;
11
14
@@ -24,6 +27,11 @@ async function main() {
24
27
numUrlsWithFragment ++ ;
25
28
}
26
29
30
+ if ( ! validEndings . some ( ( ending ) => from . endsWith ( ending ) ) ) {
31
+ console . log ( `✘ Found unslashed source URLs:\n ${ from } ` ) ;
32
+ numNonSlashedRedirects ++ ;
33
+ }
34
+
27
35
if ( redirectSourceUrls . includes ( from ) ) {
28
36
console . log ( `✘ Found repeated source URL:\n ${ from } ` ) ;
29
37
numDuplicateRedirects ++ ;
@@ -32,7 +40,12 @@ async function main() {
32
40
}
33
41
}
34
42
35
- if ( numInfiniteRedirects || numUrlsWithFragment || numDuplicateRedirects ) {
43
+ if (
44
+ numInfiniteRedirects ||
45
+ numUrlsWithFragment ||
46
+ numDuplicateRedirects ||
47
+ numNonSlashedRedirects
48
+ ) {
36
49
console . log ( "\nDetected errors:" ) ;
37
50
38
51
if ( numInfiniteRedirects > 0 ) {
@@ -47,6 +60,12 @@ async function main() {
47
60
console . log ( `- ${ numDuplicateRedirects } repeated source URL(s)` ) ;
48
61
}
49
62
63
+ if ( numNonSlashedRedirects > 0 ) {
64
+ console . log (
65
+ `- ${ numNonSlashedRedirects } need slashes at the end of the source URL` ,
66
+ ) ;
67
+ }
68
+
50
69
console . log ( "\nPlease fix the errors above before merging :)" ) ;
51
70
process . exit ( 1 ) ;
52
71
} else {
0 commit comments