Comparing version 1.3.0 to 1.4.0
21
index.js
@@ -25,5 +25,4 @@ var url = require('url') | ||
// flatten list and filter out any falsy values | ||
routes = routes.reduce(function flatten (flat, route) { | ||
return flat.concat(route) | ||
}, Array.isArray(opts.urls) ? opts.urls : [opts.urls]).filter(Boolean) | ||
var initial = Array.isArray(opts.urls) ? opts.urls : [opts.urls] | ||
routes = flatten(routes, initial).filter(Boolean).map(resolveRoot) | ||
@@ -48,8 +47,5 @@ if (routes.length <= limit) { | ||
function resolveRoute (route, done) { | ||
if (!/\/:/.test(route)) return done(null, resolveRoot(route)) | ||
if (!/\/:/.test(route)) return done(null, route) | ||
assert(opts.resolve, 'cccpurge: opts.resolve should be a function') | ||
opts.resolve(route, function (err, routes) { | ||
if (!Array.isArray(routes)) routes = [routes] | ||
done(err, routes.map(resolveRoot)) | ||
}) | ||
opts.resolve(route, done) | ||
} | ||
@@ -110,1 +106,10 @@ | ||
} | ||
// flatten array | ||
// (arr, initial?) -> arr | ||
function flatten (arr, initial) { | ||
initial = initial || [] | ||
return arr.reduce(function (flat, value) { | ||
return flat.concat(value) | ||
}, initial) | ||
} |
{ | ||
"name": "cccpurge", | ||
"version": "1.3.0", | ||
"version": "1.4.0", | ||
"description": "Choo Cloudflare Cache Purge – purge all routes served by choo app", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
7756
97