diff --git a/tools/scripts/build/__snapshots__/create-redirects.test.js.snap b/tools/scripts/build/__snapshots__/create-redirects.test.js.snap index 41458fadce..dfb4a3183a 100644 --- a/tools/scripts/build/__snapshots__/create-redirects.test.js.snap +++ b/tools/scripts/build/__snapshots__/create-redirects.test.js.snap @@ -3,8 +3,22 @@ exports[`createRedirects matches the snapshot 1`] = ` "#api redirect +# client-route proxy /internal/* https://api.example.com/internal/:splat 200 +# applications +/news/* https://news.example.com/:splat 200 +/forum/* https://forum.example.com/:splat 200 + +# pages +/about https://news.example.com/about +/terms-of-service https://news.example.com/terms-of-service +/terms https://news.example.com/terms-of-service +/academic-honesty https://news.example.com/academic-honesty +/code-of-conduct https://news.example.com/code-of-conduct +/privacy-policy https://news.example.com/privacy-policy +/privacy https://news.example.com/privacy-policy + # auth redirects /signin https://api.example.com/signin 200 /signup https://api.example.com/signin 200 @@ -30,19 +44,17 @@ exports[`createRedirects matches the snapshot 1`] = ` /chat https://gitter.im/FreeCodeCamp/FreeCodeCamp 301 /twitch https://twitch.tv/freecodecamp 301 /nonprofits-form / 301 +/nonprofits / 301 +/Nonprofits / 301 /pmi-acp-agile-project-managers / 301 /pmi-acp-agile-project-managers-form / 301 /stories / 301 /all-stories / 301 -/field-guide/* /forum 301 -/learn-to-code /learn 200 +/field-guide/* / 301 +/learn-to-code /learn 301 /map /learn 200 -/news https://news.example.com 200 -/news/* https://news.example.com/:splat 200 -/forum/* https://forum.example.com/:splat 200 -/privacy https://forum.example.com/t/free-code-camp-privacy-policy/19545 301 -/nonprofit-project-instructions https://forum.example.com/t/how-free-code-camps-nonprofits-projects-work/19547 301 -/how-nonprofit-projects-work https://www.freecodecamp.org/news/open-source-for-good-1a0ea9f32d5a 301 +/nonprofit-project-instructions / 301 +/how-nonprofit-projects-work / 301 " `; diff --git a/tools/scripts/build/create-redirects.js b/tools/scripts/build/create-redirects.js index e34b8a4fb7..ccf591aeca 100644 --- a/tools/scripts/build/create-redirects.js +++ b/tools/scripts/build/create-redirects.js @@ -24,8 +24,22 @@ exports.createRedirects = function createRedirects(locations) { /* eslint-disable max-len */ const template = `#api redirect +# client-route proxy /internal/* #{{API}}/internal/:splat 200 +# applications +/news/* #{{NEWS}}/:splat 200 +/forum/* #{{FORUM}}/:splat 200 + +# pages +/about #{{NEWS}}/about +/terms-of-service #{{NEWS}}/terms-of-service +/terms #{{NEWS}}/terms-of-service +/academic-honesty #{{NEWS}}/academic-honesty +/code-of-conduct #{{NEWS}}/code-of-conduct +/privacy-policy #{{NEWS}}/privacy-policy +/privacy #{{NEWS}}/privacy-policy + # auth redirects /signin #{{API}}/signin 200 /signup #{{API}}/signin 200 @@ -51,19 +65,17 @@ const template = `#api redirect /chat https://gitter.im/FreeCodeCamp/FreeCodeCamp 301 /twitch https://twitch.tv/freecodecamp 301 /nonprofits-form / 301 +/nonprofits / 301 +/Nonprofits / 301 /pmi-acp-agile-project-managers / 301 /pmi-acp-agile-project-managers-form / 301 /stories / 301 /all-stories / 301 -/field-guide/* /forum 301 -/learn-to-code /learn 200 +/field-guide/* / 301 +/learn-to-code /learn 301 /map /learn 200 -/news #{{NEWS}} 200 -/news/* #{{NEWS}}/:splat 200 -/forum/* #{{FORUM}}/:splat 200 -/privacy #{{FORUM}}/t/free-code-camp-privacy-policy/19545 301 -/nonprofit-project-instructions #{{FORUM}}/t/how-free-code-camps-nonprofits-projects-work/19547 301 -/how-nonprofit-projects-work https://www.freecodecamp.org/news/open-source-for-good-1a0ea9f32d5a 301 +/nonprofit-project-instructions / 301 +/how-nonprofit-projects-work / 301 `; /* eslint-enable max-len */ diff --git a/tools/scripts/build/create-redirects.test.js b/tools/scripts/build/create-redirects.test.js index 9ebb22c727..9b51358c0d 100644 --- a/tools/scripts/build/create-redirects.test.js +++ b/tools/scripts/build/create-redirects.test.js @@ -18,7 +18,7 @@ describe('createRedirects', () => { }); it('replaces instances of `#{{...}}` with the locations provided', () => { - expect.assertions(6); + expect.assertions(5); const apiPlaceholderRE = /#\{\{API\}\}/; const newsPlaceholderRE = /#\{\{NEWS\}\}/; @@ -35,9 +35,6 @@ describe('createRedirects', () => { const { api, forum } = testLocations; expect(redirects.includes(`${api}/internal/:splat`)).toBe(true); - expect( - redirects.includes(`${forum}/t/free-code-camp-privacy-policy/19545 301`) - ).toBe(true); expect(redirects.includes(`${forum}`)).toBe(true); });