fix(redirects): update app paths and other misc. (#36635)

This commit is contained in:
mrugesh 2019-08-19 19:17:27 +05:30 committed by GitHub
parent 9f40714d0a
commit 985daf5e5a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 41 additions and 20 deletions

View File

@ -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
"
`;

View File

@ -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 */

View File

@ -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);
});