This repository was archived by the owner on May 10, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -36,10 +36,18 @@ const setupRedirects = (publishPath) => {
3636 // less-specific routes (e.g., catch-all)
3737 const sortedRoutes = getSortedRoutes ( nextRedirects . map ( ( { route } ) => route ) ) ;
3838
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+
3947 // Assemble redirects for each route
4048 sortedRoutes . forEach ( ( route ) => {
4149 const nextRedirect = nextRedirects . find (
42- ( redirect ) => redirect . route === route && ! redirect . added
50+ ( redirect ) => redirect . route === route && ! wasRedirectAdded ( redirect )
4351 ) ;
4452
4553 // One route may map to multiple Netlify routes: e.g., catch-all pages
@@ -60,8 +68,6 @@ const setupRedirects = (publishPath) => {
6068 const redirect = redirectPieces . join ( " " ) . trim ( ) ;
6169 logItem ( redirect ) ;
6270 redirects . push ( redirect ) ;
63- // Enables us to add colliding route redirects
64- nextRedirect . added = true ;
6571 } ) ;
6672 } ) ;
6773
You can’t perform that action at this time.
0 commit comments