idealley / feathers-hooks-rediscache

Set of caching hooks and routes for feathersjs.
MIT License
38 stars 12 forks source link

Route Subfolders break cache clearing #54

Closed jamesvillarrubia closed 5 years ago

jamesvillarrubia commented 6 years ago

Steps to reproduce

Setup cache on a nested route with a version number ahead of the service. Example: example.com/v1/resources/1?test=true

To clear the cache, I'm running GET cache/clear/single/v1/resources/1?test=true

Expected behavior

Cache key should be 'v1/resources/1?test=true'

Actual behavior

Error. Cannot find path.

Proposed Solution (What worked for me)

 router.get('/clear/single/:target', (req, res) => {
    let target = decodeURIComponent(req.params.target);

becomes

  router.get('/clear/single/*', (req, res) => {
    let target = decodeURIComponent(req.params[0]); 

If this sounds like a useful tweak, I'm happy to submit a PR.

idealley commented 5 years ago

Thank you!