| 
									
										
										
										
											2018-10-08 00:00:50 +01:00
										 |  |  | const apiPlaceholderRE = /#\{\{API\}\}/g; | 
					
						
							| 
									
										
										
										
											2019-02-05 18:08:40 +00:00
										 |  |  | const newsPlaceholderRE = /#\{\{NEWS\}\}/g; | 
					
						
							| 
									
										
										
										
											2018-10-08 00:00:50 +01:00
										 |  |  | const forumPlacehilderRE = /#\{\{FORUM\}\}/g; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | exports.createRedirects = function createRedirects(locations) { | 
					
						
							| 
									
										
										
										
											2019-10-07 16:42:07 -07:00
										 |  |  |   const { api, newsProxy, forumProxy } = locations; | 
					
						
							| 
									
										
										
										
											2018-10-08 00:00:50 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-07 16:42:07 -07:00
										 |  |  |   if (!(api && newsProxy && forumProxy)) { | 
					
						
							| 
									
										
										
										
											2018-10-08 00:00:50 +01:00
										 |  |  |     throw new Error(`One or more locations are missing, all are required.
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     api: ${api} | 
					
						
							| 
									
										
										
										
											2019-10-07 16:42:07 -07:00
										 |  |  |     newsProxy: ${newsProxy} | 
					
						
							|  |  |  |     forumProxy: ${forumProxy} | 
					
						
							| 
									
										
										
										
											2018-10-08 00:00:50 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     `);
 | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   return template | 
					
						
							|  |  |  |     .replace(apiPlaceholderRE, api) | 
					
						
							| 
									
										
										
										
											2019-10-07 16:42:07 -07:00
										 |  |  |     .replace(newsPlaceholderRE, newsProxy) | 
					
						
							|  |  |  |     .replace(forumPlacehilderRE, forumProxy); | 
					
						
							| 
									
										
										
										
											2018-10-08 00:00:50 +01:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* eslint-disable max-len */ | 
					
						
							| 
									
										
										
										
											2019-08-19 22:48:03 +05:30
										 |  |  | const template = `
 | 
					
						
							|  |  |  | # | 
					
						
							|  |  |  | # WARNING: The order of this list is very important. | 
					
						
							|  |  |  | # | 
					
						
							| 
									
										
										
										
											2018-10-08 00:00:50 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-15 18:32:35 +05:30
										 |  |  | # domain mappings | 
					
						
							|  |  |  | https://freecodecamp-dev.netlify.com/*        https://www.freecodecamp.dev/:splat 301!
 | 
					
						
							|  |  |  | https://freecodecamp-org.netlify.com/*        https://www.freecodecamp.org/:splat 301!
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-19 22:48:03 +05:30
										 |  |  | #api redirect | 
					
						
							| 
									
										
										
										
											2019-10-16 17:17:57 +05:30
										 |  |  | /internal/*                                   #{{API}}/internal/:splat 200! | 
					
						
							| 
									
										
										
										
											2018-10-08 00:00:50 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-19 22:48:03 +05:30
										 |  |  | # pages | 
					
						
							|  |  |  | /about                                        #{{NEWS}}/about 200 | 
					
						
							|  |  |  | /academic-honesty                             #{{NEWS}}/academic-honesty 200 | 
					
						
							|  |  |  | /code-of-conduct                              #{{NEWS}}/code-of-conduct 200 | 
					
						
							| 
									
										
										
										
											2019-08-29 08:45:35 -05:00
										 |  |  | /copyright                                    #{{NEWS}}/copyright-policy 200 | 
					
						
							|  |  |  | /copyright-policy                             #{{NEWS}}/copyright-policy 200 | 
					
						
							| 
									
										
										
										
											2019-08-19 22:48:03 +05:30
										 |  |  | /privacy                                      #{{NEWS}}/privacy-policy 200 | 
					
						
							|  |  |  | /privacy-policy                               #{{NEWS}}/privacy-policy 200 | 
					
						
							| 
									
										
										
										
											2019-09-04 18:13:37 +05:30
										 |  |  | /shop                                         #{{NEWS}}/shop 200 | 
					
						
							| 
									
										
										
										
											2019-09-15 10:36:11 +03:00
										 |  |  | /software-resources-for-nonprofits            #{{NEWS}}/software-resources-for-nonprofits 200 | 
					
						
							| 
									
										
										
										
											2019-08-19 22:48:03 +05:30
										 |  |  | /sponsors                                     #{{NEWS}}/sponsors 200 | 
					
						
							|  |  |  | /support                                      #{{NEWS}}/support 200 | 
					
						
							|  |  |  | /terms                                        #{{NEWS}}/terms-of-service 200 | 
					
						
							|  |  |  | /terms-of-service                             #{{NEWS}}/terms-of-service 200 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-19 19:17:27 +05:30
										 |  |  | # applications | 
					
						
							| 
									
										
										
										
											2019-09-04 18:13:37 +05:30
										 |  |  | /forum/*                                      #{{FORUM}}/:splat 200 | 
					
						
							| 
									
										
										
										
											2019-08-20 00:22:08 +05:30
										 |  |  | /news                                         #{{NEWS}}/ 200 | 
					
						
							| 
									
										
										
										
											2019-08-19 19:17:27 +05:30
										 |  |  | /news/*                                       #{{NEWS}}/:splat 200 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-08 00:00:50 +01:00
										 |  |  | # auth redirects | 
					
						
							| 
									
										
										
										
											2019-10-16 17:17:57 +05:30
										 |  |  | /deprecated-signin                            #{{API}}/signin 200! | 
					
						
							|  |  |  | /email-signin                                 #{{API}}/signin 200! | 
					
						
							|  |  |  | /login                                        #{{API}}/signin 200! | 
					
						
							|  |  |  | /logout                                       #{{API}}/signout 200! | 
					
						
							|  |  |  | /passwordless-change                          #{{API}}/confirm-email 200! | 
					
						
							|  |  |  | /signin                                       #{{API}}/signin 200! | 
					
						
							|  |  |  | /signup                                       #{{API}}/signin 200! | 
					
						
							| 
									
										
										
										
											2018-10-08 00:00:50 +01: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 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-29 08:45:35 -05:00
										 |  |  | # unsubscribe redirects | 
					
						
							| 
									
										
										
										
											2019-10-16 17:17:57 +05:30
										 |  |  | /u/*                                          #{{API}}/u/:splat 200! | 
					
						
							|  |  |  | /ue/*                                         #{{API}}/ue/:splat 200! | 
					
						
							|  |  |  | /unsubscribe/*                                #{{API}}/unsubscribe/:splat 200! | 
					
						
							| 
									
										
										
										
											2018-10-08 00:00:50 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | # misc redirects | 
					
						
							| 
									
										
										
										
											2019-02-04 11:42:31 +00:00
										 |  |  | /agile                                        / 301 | 
					
						
							|  |  |  | /all-stories                                  / 301 | 
					
						
							| 
									
										
										
										
											2019-09-04 18:13:37 +05:30
										 |  |  | /chat                                         https://gitter.im/FreeCodeCamp/FreeCodeCamp 301 | 
					
						
							| 
									
										
										
										
											2019-08-19 19:17:27 +05:30
										 |  |  | /field-guide/*                                / 301 | 
					
						
							| 
									
										
										
										
											2019-09-04 18:13:37 +05:30
										 |  |  | /how-nonprofit-projects-work                  / 301 | 
					
						
							| 
									
										
										
										
											2019-08-19 19:17:27 +05:30
										 |  |  | /learn-to-code                                /learn 301 | 
					
						
							| 
									
										
										
										
											2018-10-08 00:00:50 +01:00
										 |  |  | /map                                          /learn 200 | 
					
						
							| 
									
										
										
										
											2019-08-19 19:17:27 +05:30
										 |  |  | /nonprofit-project-instructions               / 301 | 
					
						
							| 
									
										
										
										
											2019-09-04 18:13:37 +05:30
										 |  |  | /Nonprofits                                   / 301 | 
					
						
							|  |  |  | /nonprofits                                   / 301 | 
					
						
							|  |  |  | /nonprofits-form                              / 301 | 
					
						
							|  |  |  | /pmi-acp-agile-project-managers               / 301 | 
					
						
							|  |  |  | /pmi-acp-agile-project-managers-form          / 301 | 
					
						
							|  |  |  | /stories                                      / 301 | 
					
						
							|  |  |  | /twitch                                       https://twitch.tv/freecodecamp 301 | 
					
						
							|  |  |  | /welcome                                      / 200 | 
					
						
							| 
									
										
										
										
											2018-10-08 00:00:50 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | `;
 | 
					
						
							|  |  |  | /* eslint-enable max-len */ |