strapi-middleware-cache
strapi-middleware-cache copied to clipboard
Faulty logic in param matching for getRouteRegExp
The matching of params when creating the regex is breaking since params extracted from the route will have format [":param1", ":param2"]
while the ones added wont have the :
since they are likely used as:
getCacheConfRegExp(cacheConf, {
param1,
param2,
});
Even if you explicitly name the params
getCacheConfRegExp(cacheConf, {
":param1": param1,
":param2": param2,
});
the pattern-replace will fail in the loop a few lines down since it then tries to match ::param1
which doesn't exist in the route
pattern = pattern.replace(`:${paramName}`, params[paramName]);
Opened a PR with a quick fix for this: https://github.com/patrixr/strapi-middleware-cache/pull/70
Ought to be non-breaking?
@patrixr have you had the chance to take a look at this?