diff --git a/bin/configure-fastly.js b/bin/configure-fastly.js index 729227d48..0a3838747 100644 --- a/bin/configure-fastly.js +++ b/bin/configure-fastly.js @@ -18,9 +18,9 @@ var fastly = require('./lib/fastly-extended')(process.env.FASTLY_API_KEY, FASTLY var extraAppRoutes = [ // Homepage with querystring. // TODO: Should this be added for every route? - '^/\\?', + '/\\?', // View html - '^/[^\/]*\.html$' + '/[^\/]*\.html$' ]; /* @@ -35,7 +35,7 @@ var getStaticPaths = function (pathToStatic) { }).map(function (pathName) { // Reduce absolute path to relative paths like '/js' var base = path.dirname(path.resolve(__dirname, pathToStatic)); - return '^' + pathName.replace(base, '') + (path.extname(pathName) ? '' : '/'); + return pathName.replace(base, '') + (path.extname(pathName) ? '' : '/'); }); }; @@ -66,9 +66,9 @@ var expressPatternToRegex = function (pattern) { * string suitable for a Fastly condition */ var pathsToCondition = function (paths) { - return 'req.url~"' + paths.reduce(function (conditionString, pattern) { + return 'req.url~^("' + paths.reduce(function (conditionString, pattern) { return conditionString + (conditionString ? '|' : '') + pattern; - }, '') + '"'; + }, '') + ')"'; }; /* diff --git a/src/routes.json b/src/routes.json index dfdd31626..27f57fa5a 100644 --- a/src/routes.json +++ b/src/routes.json @@ -2,39 +2,42 @@ { "name": "splash", "pattern": "^/?$", + "routeAlias": "/?$", "view": "splash/splash", "title": "Imagine, Program, Share" }, { "name": "about", "pattern": "^/about/?$", + "routeAlias": "/about/?$", "view": "about/about", "title": "About" }, { "name": "guidelines", "pattern": "^/community_guidelines/?$", + "routeAlias": "/community_guidelines/?$", "view": "guidelines/guidelines", "title": "Scratch Community Guidelines" }, { "name": "student-complete-registration", "pattern": "^/classes/complete_registration", - "routeAlias": "^/classes/(complete_registration|.+/register/.+)", + "routeAlias": "/classes/(complete_registration|.+/register/.+)", "view": "studentcompleteregistration/studentcompleteregistration", "title": "Complete your Registration" }, { "name": "student-registration", "pattern": "^/classes/:id/register/:token", - "routeAlias": "^/classes/(complete_registration|.+/register/.+)", + "routeAlias": "/classes/(complete_registration|.+/register/.+)", "view": "studentregistration/studentregistration", "title": "Class Registration" }, { "name": "conference-index", "pattern": "^/conference/?$", - "routeAlias": "^/conference(?!/201[4-5])", + "routeAlias": "/conference(?!/201[4-5])", "view": "conference/index/index", "title": "Scratch Conference", "viewportWidth": "device-width" @@ -42,7 +45,7 @@ { "name": "conference-plan", "pattern": "^/conference/plan/?$", - "routeAlias": "^/conference(?!/201[4-5])", + "routeAlias": "/conference(?!/201[4-5])", "view": "conference/plan/plan", "title": "Plan Your Visit", "viewportWidth": "device-width" @@ -50,7 +53,7 @@ { "name": "conference-expectations", "pattern": "^/conference/expect/?$", - "routeAlias": "^/conference(?!/201[4-5])", + "routeAlias": "/conference(?!/201[4-5])", "view": "conference/expect/expect", "title": "What to Expect", "viewportWidth": "device-width" @@ -58,7 +61,7 @@ { "name": "conference-schedule", "pattern": "^/conference/schedule/?$", - "routeAlias": "^/conference(?!/201[4-5])", + "routeAlias": "/conference(?!/201[4-5])", "view": "conference/schedule/schedule", "title": "Conference Schedule", "viewportWidth": "device-width" @@ -66,7 +69,7 @@ { "name": "conference-details", "pattern": "^/conference/:id/details/?$", - "routeAlias": "^/conference(?!/201[4-5])", + "routeAlias": "/conference(?!/201[4-5])", "view": "conference/details/details", "title": "Event Details", "viewportWidth": "device-width" @@ -74,30 +77,35 @@ { "name": "developers", "pattern": "^/developers/?$", + "routeAlias": "/developers/?$", "view": "developers/developers", "title": "Developers" }, { "name": "dmca", "pattern": "^/DMCA/?$", + "routeAlias": "/DMCA/?$", "view": "dmca/dmca", "title": "DMCA" }, { "name": "educator-landing", "pattern": "^/educators/?$", + "routeAlias": "/educators(?:/(faq|register|waiting))?/?$", "view": "teachers/landing/landing", "title": "Educators" }, { "name": "teacher-faq", "pattern": "^/educators/faq/?$", + "routeAlias": "/educators(?:/(faq|register|waiting))?/?$", "view": "teachers/faq/faq", "title": "Teacher Accounts FAQ" }, { "name": "teacherregistration", "pattern": "^/educators/register$", + "routeAlias": "/educators(?:/(faq|register|waiting))?/?$", "view": "teacherregistration/teacherregistration", "title": "Teacher Registration", "viewportWidth": "device-width" @@ -105,98 +113,109 @@ { "name": "teacherwaitingroom", "pattern": "^/educators/waiting", + "routeAlias": "/educators(?:/(faq|register|waiting))?/?$", "view": "teacherwaitingroom/teacherwaitingroom", "title": "Thank you for requesting a Scratch Teacher Account" }, { "name": "explore", "pattern": "^/explore/:projects/:all/?$", - "routeAlias": "^/explore(?!/ajax)", + "routeAlias": "/explore(?!/ajax)", "view": "explore/explore", "title": "Explore" }, { "name": "hoc", "pattern": "^/hoc/?$", + "routeAlias": "/hoc/?$", "view": "hoc/hoc", "title": "Hour of Code" }, { "name": "cards", "pattern": "^/info/cards/?$", + "routeAlias": "/info/(cards|communityblocks-interviews|credits|faq)/?$", "view": "cards/cards", "title": "Cards" }, { "name": "communityblocks-interviews", "pattern": "^/info/communityblocks-interviews/?$", + "routeAlias": "/info/(cards|communityblocks-interviews|credits|faq|donate)/?$", "view": "communityblocks-interviews/communityblocks-interviews", "title": "Community Blocks Beta Tester Interviews" }, { "name": "credits", "pattern": "^/info/credits/?$", + "routeAlias": "/info/(cards|communityblocks-interviews|credits|faq)/?$", "view": "credits/credits", "title": "Credits" }, { "name": "faq", "pattern": "^/info/faq/?$", + "routeAlias": "/info/(cards|communityblocks-interviews|credits|faq)/?$", "view": "faq/faq", "title": "FAQ" }, { "name": "jobs", "pattern": "^/jobs/?$", + "routeAlias": "/jobs/?$", "view": "jobs/jobs", "title": "Jobs" }, { "name": "privacypolicy", "pattern": "^/privacy_policy/?$", + "routeAlias": "/privacy_policy/?$", "view": "privacypolicy/privacypolicy", "title": "Privacy Policy" }, { "name": "search", "pattern": "^/search/:projects?$/?$", - "routeAlias": "^/search", + "routeAlias": "/search", "view": "search/search", "title": "Search" }, { "name": "terms", "pattern": "^/terms_of_use/?$", + "routeAlias": "/terms_of_use/?$", "view": "terms/terms", "title": "Scratch Terms of Use" }, { "name": "wedo2", "pattern": "^/wedo/?$", + "routeAlias": "/wedo/?$", "view": "wedo2/wedo2", "title": "LEGO WeDo 2.0" }, { "name": "donate", "pattern": "^/info/donate/?", + "routeAlias": "/info/(cards|communityblocks-interviews|credits|faq|donate)/?$", "redirect": "https://secure.donationpay.org/scratchfoundation/" }, { "name": "explore-redirect", "pattern": "^/explore/?$", - "routeAlias": "^/explore(?!/ajax)", + "routeAlias": "/explore(?!/ajax)", "redirect": "/explore/projects/all" }, { "name": "explore-projects-redirect", "pattern": "^/explore/projects/?$", - "routeAlias": "^/explore(?!/ajax)", + "routeAlias": "/explore(?!/ajax)", "redirect": "/explore/projects/all" }, { "name": "explore-studios-redirect", "pattern": "^/explore/studios/?$", - "routeAlias": "^/explore(?!/ajax)", + "routeAlias": "/explore(?!/ajax)", "redirect": "/explore/studios/all" } ]