mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2024-11-26 17:16:11 -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 .+?
|
* all :arguments become .+?
|
||||||
*/
|
*/
|
||||||
expressPatternToRegex: function (pattern) {
|
expressPatternToRegex: function (pattern) {
|
||||||
return pattern.replace(/(:[^/]+)/gi, '.+?');
|
pattern = pattern.replace(/(:\w+)(\([^\)]+\))/gi, '$2');
|
||||||
|
return pattern.replace(/(:\w+)/gi, '.+?');
|
||||||
},
|
},
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -127,7 +127,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "explore",
|
"name": "explore",
|
||||||
"pattern": "^/explore/:projects/:all/?$",
|
"pattern": "^/explore/:projects(projects|studios)/:all/?$",
|
||||||
"routeAlias": "/explore(?!/ajax)",
|
"routeAlias": "/explore(?!/ajax)",
|
||||||
"view": "explore/explore",
|
"view": "explore/explore",
|
||||||
"title": "Explore"
|
"title": "Explore"
|
||||||
|
|
Loading…
Reference in a new issue