Skip to content

Commit 3160962

Browse files
committed
chore: does this fix node 10 test
1 parent d0fb79c commit 3160962

File tree

2 files changed

+26
-16
lines changed

2 files changed

+26
-16
lines changed

src/lib/steps/setupRedirects.js

+11-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,17 @@ const setupRedirects = async (publishPath) => {
7171
const sortedStaticRedirects = getSortedRedirects(staticRedirects)
7272
const sortedDynamicRedirects = getSortedRedirects(dynamicRedirects)
7373

74-
const basePathSortFunc = (a, b) => (a.target.includes(basePath) ? -1 : 1)
74+
const basePathSortFunc = (a, b) => {
75+
if (a.target.includes(basePath) && b.target.includes(basePath)) {
76+
return 0
77+
} if (a.target.includes(basePath) && !b.target.includes(basePath)) {
78+
return -1
79+
// } else if (!a.target.includes(basePath) && b.target.includes(basePath)) {
80+
// return 0
81+
}
82+
return 1
83+
84+
}
7585
const allRedirects = hasBasePath
7686
? [...sortedStaticRedirects.sort(basePathSortFunc), ...sortedDynamicRedirects.sort(basePathSortFunc)]
7787
: [...sortedStaticRedirects, ...sortedDynamicRedirects]

src/tests/__snapshots__/basePath.test.js.snap

+15-15
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
exports[`Routing creates Netlify redirects 1`] = `
44
"# Next-on-Netlify Redirects
5-
/getStaticProps/withRevalidate/2 /foo/getStaticProps/withRevalidate/2 301!
6-
/getStaticProps/withRevalidate/1 /foo/getStaticProps/withRevalidate/1 301!
7-
/getStaticProps/with-revalidate /foo/getStaticProps/with-revalidate 301!
8-
/getServerSideProps/static /foo/getServerSideProps/static 301!
9-
/api/static /foo/api/static 301!
10-
/api/hello-background /foo/api/hello-background 301!
115
/ /foo 301!
6+
/api/hello-background /foo/api/hello-background 301!
7+
/api/static /foo/api/static 301!
8+
/getServerSideProps/static /foo/getServerSideProps/static 301!
9+
/getStaticProps/with-revalidate /foo/getStaticProps/with-revalidate 301!
10+
/getStaticProps/withRevalidate/1 /foo/getStaticProps/withRevalidate/1 301!
11+
/getStaticProps/withRevalidate/2 /foo/getStaticProps/withRevalidate/2 301!
1212
/_next/data/%BUILD_ID%/getServerSideProps/static.json /.netlify/functions/next_getServerSideProps_static 200
1313
/_next/data/%BUILD_ID%/getStaticProps/1.json /.netlify/functions/next_getStaticProps_id 200! Cookie=__prerender_bypass,__next_preview_data
1414
/_next/data/%BUILD_ID%/getStaticProps/2.json /.netlify/functions/next_getStaticProps_id 200! Cookie=__prerender_bypass,__next_preview_data
@@ -39,17 +39,17 @@ exports[`Routing creates Netlify redirects 1`] = `
3939
/foo/getStaticProps/withFallbackBlocking/4 /.netlify/functions/next_getStaticProps_withFallbackBlocking_id 200 Cookie=__prerender_bypass,__next_preview_data
4040
/foo/getStaticProps/withRevalidate/1 /.netlify/functions/next_getStaticProps_withRevalidate_id 200
4141
/foo/getStaticProps/withRevalidate/2 /.netlify/functions/next_getStaticProps_withRevalidate_id 200
42-
/shows/:params/* /foo/shows/:params 301!
43-
/shows/:id /foo/shows/:id 301!
44-
/getStaticProps/withRevalidate/withFallback/:id /foo/getStaticProps/withRevalidate/withFallback/:id 301!
45-
/getStaticProps/withFallbackBlocking/:id /foo/getStaticProps/withFallbackBlocking/:id 301!
46-
/getStaticProps/withFallback/:slug/* /foo/getStaticProps/withFallback/:slug 301!
47-
/getStaticProps/withFallback/:id /foo/getStaticProps/withFallback/:id 301!
48-
/getServerSideProps/:id /foo/getServerSideProps/:id 301!
42+
/api/shows/:id /foo/api/shows/:id 301!
43+
/api/shows/:params/* /foo/api/shows/:params 301!
4944
/getServerSideProps/all /foo/getServerSideProps/all/:[slug] 301!
5045
/getServerSideProps/all/* /foo/getServerSideProps/all/:[slug] 301!
51-
/api/shows/:params/* /foo/api/shows/:params 301!
52-
/api/shows/:id /foo/api/shows/:id 301!
46+
/getServerSideProps/:id /foo/getServerSideProps/:id 301!
47+
/getStaticProps/withFallback/:id /foo/getStaticProps/withFallback/:id 301!
48+
/getStaticProps/withFallback/:slug/* /foo/getStaticProps/withFallback/:slug 301!
49+
/getStaticProps/withFallbackBlocking/:id /foo/getStaticProps/withFallbackBlocking/:id 301!
50+
/getStaticProps/withRevalidate/withFallback/:id /foo/getStaticProps/withRevalidate/withFallback/:id 301!
51+
/shows/:id /foo/shows/:id 301!
52+
/shows/:params/* /foo/shows/:params 301!
5353
/_next/data/%BUILD_ID%/getServerSideProps/all.json /.netlify/functions/next_getServerSideProps_all_slug 200
5454
/_next/data/%BUILD_ID%/getServerSideProps/all/* /.netlify/functions/next_getServerSideProps_all_slug 200
5555
/_next/data/%BUILD_ID%/getServerSideProps/:id.json /.netlify/functions/next_getServerSideProps_id 200

0 commit comments

Comments
 (0)