This repository was archived by the owner on May 10, 2021. It is now read-only.
File tree 1 file changed +9
-3
lines changed
1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -36,10 +36,18 @@ const setupRedirects = (publishPath) => {
36
36
// less-specific routes (e.g., catch-all)
37
37
const sortedRoutes = getSortedRoutes ( nextRedirects . map ( ( { route } ) => route ) ) ;
38
38
39
+ // There may be several redirects with the same route but different targets
40
+ const wasRedirectAdded = ( redirect ) => {
41
+ return redirects . find ( ( addedRedirect ) => {
42
+ const [ route , target ] = addedRedirect . split ( " " ) ;
43
+ return redirect . route === route && redirect . target === target ;
44
+ } ) ;
45
+ } ;
46
+
39
47
// Assemble redirects for each route
40
48
sortedRoutes . forEach ( ( route ) => {
41
49
const nextRedirect = nextRedirects . find (
42
- ( redirect ) => redirect . route === route && ! redirect . added
50
+ ( redirect ) => redirect . route === route && ! wasRedirectAdded ( redirect )
43
51
) ;
44
52
45
53
// One route may map to multiple Netlify routes: e.g., catch-all pages
@@ -60,8 +68,6 @@ const setupRedirects = (publishPath) => {
60
68
const redirect = redirectPieces . join ( " " ) . trim ( ) ;
61
69
logItem ( redirect ) ;
62
70
redirects . push ( redirect ) ;
63
- // Enables us to add colliding route redirects
64
- nextRedirect . added = true ;
65
71
} ) ;
66
72
} ) ;
67
73
You can’t perform that action at this time.
0 commit comments