Add additional folders to the Protecting files plugin

@texnixe I use your plugin to protect files. It works as expected. I would like to extend the functionality to protect several folders that are structured according to the following scheme:

downloads-mueller
downloads-mayer
downloads-schmidt
etc.

Each customer receives their own folder with downloads. However, the name must be flexible, as new customers are constantly being added. It would be cumbersome to do this in the plugin code.
Is it easy to add a placeholder to the script?
Or would it be better to change the folder structure, as this is protected with
(:any) are protected?

downloads/mueller
downloads/mayer
downloads/schmidt

It doesn’t really matter, you can adapt the routes as needed, if you want to have a patterns that starts with downloads-* use a regex pattern, e.g.

'pattern' => '(downloads-[a-z]*)/(:any)',

That looks good. However, I am now stuck a few lines further down because the regex pattern is causing the file not to be found when downloading.

if (kirby()->user() &&
          ($page = page('downloads-[a-z]*')) &&
          $file = $page->files()->findBy('filename', $filename)) {
          return $file->download();
        }

Na, you can’t use the regex pattern to find the page

'pattern' => '(downloads-[a-z]*)/(:any)',
'action'  => function ($pagename, $filename) {

        if (kirby()->user() &&
          ($page = page($pagename)) &&
          $file = $page->files()->findBy('filename', $filename)) {
          return $file->download();
        }
        return site()->errorPage();		
}

THANK YOU :pray: The weekend can come!
Why am I always looking for complicated solutions when it just works simple :wink: