mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2024-11-22 15:17:53 -05:00
Use regex in express patterns to limit scope
This fixes https://github.com/LLK/scratchr2/issues/3798 by using regex in expressjs patterns, and then also parsing those regex patterns for fastly, such that we can limit the scope of the regex created for a specific view
This commit is contained in:
parent
30bd5e435d
commit
87da9f3d8a
2 changed files with 3 additions and 2 deletions
|
@ -37,7 +37,8 @@ var FastlyConfigMethods = {
|
|||
* all :arguments become .+?
|
||||
*/
|
||||
expressPatternToRegex: function (pattern) {
|
||||
return pattern.replace(/(:[^/]+)/gi, '.+?');
|
||||
pattern = pattern.replace(/(:\w+)(\([^\)]+\))/gi, '$2');
|
||||
return pattern.replace(/(:\w+)/gi, '.+?');
|
||||
},
|
||||
|
||||
/*
|
||||
|
|
|
@ -127,7 +127,7 @@
|
|||
},
|
||||
{
|
||||
"name": "explore",
|
||||
"pattern": "^/explore/:projects/:all/?$",
|
||||
"pattern": "^/explore/:projects(projects|studios)/:all/?$",
|
||||
"routeAlias": "/explore(?!/ajax)",
|
||||
"view": "explore/explore",
|
||||
"title": "Explore"
|
||||
|
|
Loading…
Reference in a new issue