Add fastly rule for express uri patterns

convert path variables in express (i.e. dev-server) into rules that work for fastly (i.e. `.+?`). I tried to make it `\w+?`, but javascript seemed to either want no `\`'s or two `\`'s
This commit is contained in:
Matthew Taylor 2016-05-19 11:36:03 -04:00
parent cad75217f0
commit 1e57262771

View file

@ -54,6 +54,7 @@ var getViewPaths = function (routes) {
*/
var pathsToCondition = function (paths) {
return 'req.url~"' + paths.reduce(function (conditionString, pattern) {
pattern = pattern.replace(/(:[^/]+)\//gi, '.+?/');
return conditionString + (conditionString ? '|' : '') + pattern;
}, '') + '"';
};