pillarjs / path-to-regexp

Turn a path string such as `/user/:name` into a regular expression
MIT License
8.18k stars 382 forks source link

Next dynamic route with spread (...) throws 'Unexpected MODIFIER at 70, expected END' #278

Closed PSoltes closed 2 years ago

PSoltes commented 2 years ago

Hello,

this issue is linked to @sls-next issue, but unfortunately we are not getting any response from them.

Issue appears when dynamic paths like /api/files/[service-slug]/[product-group-slug]/[category-slug]/[...file-name] are processed by @sls-next. The @sls-next package converts this path to /api/files/:service-slug/:product-group-slug/:category-slug/:file-name*, which throws error in path-to-regexp function due to asterisk(*) at the end. Is this bug or correct behaviour? (as i am not that experienced with express paths)

blakeembrey commented 2 years ago

Your problem would be that you can't use dashes as the variable names, you effectively have a route that ends in -name* which is invalid. If you changed it to an underscore it'd work.

PSoltes commented 2 years ago

@blakeembrey Thanks so much for answer, i'll open issue with @sls-next to add this to docs somewhere, cause dashes in next path variables are no problem. Again thanks so much.