2018-10-07 23:00:50 +00:00
|
|
|
const apiPlaceholderRE = /#\{\{API\}\}/g;
|
2019-02-05 18:08:40 +00:00
|
|
|
const newsPlaceholderRE = /#\{\{NEWS\}\}/g;
|
2018-10-07 23:00:50 +00:00
|
|
|
const forumPlacehilderRE = /#\{\{FORUM\}\}/g;
|
|
|
|
|
|
|
|
exports.createRedirects = function createRedirects(locations) {
|
2019-02-05 18:08:40 +00:00
|
|
|
const { api, news, forum } = locations;
|
2018-10-07 23:00:50 +00:00
|
|
|
|
2019-02-05 18:08:40 +00:00
|
|
|
if (!(api && news && forum)) {
|
2018-10-07 23:00:50 +00:00
|
|
|
throw new Error(`One or more locations are missing, all are required.
|
|
|
|
|
|
|
|
api: ${api}
|
2019-02-05 18:08:40 +00:00
|
|
|
news: ${news}
|
2018-10-07 23:00:50 +00:00
|
|
|
forum: ${forum}
|
|
|
|
|
|
|
|
`);
|
|
|
|
}
|
|
|
|
|
|
|
|
return template
|
|
|
|
.replace(apiPlaceholderRE, api)
|
2019-02-05 18:08:40 +00:00
|
|
|
.replace(newsPlaceholderRE, news)
|
2019-02-04 11:42:31 +00:00
|
|
|
.replace(forumPlacehilderRE, forum);
|
2018-10-07 23:00:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* eslint-disable max-len */
|
|
|
|
const template = `#api redirect
|
|
|
|
|
2019-02-06 11:10:26 +00:00
|
|
|
/internal/* #{{API}}/internal/:splat 200
|
2018-10-07 23:00:50 +00:00
|
|
|
|
|
|
|
# auth redirects
|
2019-02-06 11:10:26 +00:00
|
|
|
/signin #{{API}}/signin 200
|
|
|
|
/signup #{{API}}/signin 200
|
|
|
|
/email-signin #{{API}}/signin 200
|
|
|
|
/login #{{API}}/signin 200
|
|
|
|
/deprecated-signin #{{API}}/signin 200
|
|
|
|
/logout #{{API}}/signout 200
|
|
|
|
/passwordless-change #{{API}}/confirm-email 200
|
2018-10-07 23:00:50 +00:00
|
|
|
|
|
|
|
# certification redirects
|
|
|
|
/:username/front-end-certification /certification/:username/legacy-front-end 301
|
|
|
|
/:username/data-visualization-certification /certification/:username/legacy-data-visualization 301
|
|
|
|
/:username/back-end-certification /certification/:username/legacy-back-end 301
|
|
|
|
/:username/full-stack-certification /certification/:username/full-stack 301
|
|
|
|
|
|
|
|
# unsunscribe redirects
|
2019-02-06 11:10:26 +00:00
|
|
|
/u/* #{{API}}/u/:splat 200
|
|
|
|
/unsunscribe/* #{{API}}/unsunscribe/:splat 200
|
|
|
|
/ue/* #{{API}}/ue/:splat 200
|
2018-10-07 23:00:50 +00:00
|
|
|
|
|
|
|
# misc redirects
|
2019-02-04 11:42:31 +00:00
|
|
|
/agile / 301
|
2018-10-07 23:00:50 +00:00
|
|
|
/chat https://gitter.im/FreeCodeCamp/FreeCodeCamp 301
|
|
|
|
/twitch https://twitch.tv/freecodecamp 301
|
2019-02-04 11:42:31 +00:00
|
|
|
/nonprofits-form / 301
|
|
|
|
/pmi-acp-agile-project-managers / 301
|
|
|
|
/pmi-acp-agile-project-managers-form / 301
|
|
|
|
/stories / 301
|
|
|
|
/all-stories / 301
|
|
|
|
/field-guide/* /forum 301
|
2018-10-07 23:00:50 +00:00
|
|
|
/learn-to-code /learn 200
|
|
|
|
/map /learn 200
|
2019-02-06 11:10:26 +00:00
|
|
|
/news #{{NEWS}} 200
|
|
|
|
/news/* #{{NEWS}}/:splat 200
|
|
|
|
/forum/* #{{FORUM}}/:splat 200
|
2019-02-05 18:08:40 +00:00
|
|
|
/privacy #{{FORUM}}/t/free-code-camp-privacy-policy/19545 301
|
|
|
|
/nonprofit-project-instructions #{{FORUM}}/t/how-free-code-camps-nonprofits-projects-work/19547 301
|
2018-10-07 23:00:50 +00:00
|
|
|
/how-nonprofit-projects-work https://medium.freecodecamp.org/open-source-for-good-1a0ea9f32d5a 301
|
|
|
|
|
|
|
|
`;
|
|
|
|
/* eslint-enable max-len */
|