Express route parsing with regex characters sets

89 views Asked by At

Path: /1,2,3,456,678 - only numbers and commas, not anything else
Should be matched with regex-like path like this: /ids:(\\d+[,\\d]*) natively
But https://www.npmjs.com/package/path-to-regexp in express compiles it to some ridiculous regex
Expressers/noders - pls guide me how to approach this right

1

There are 1 answers

0
Doc999tor On BEST ANSWER

Replacing * with {0,} solved the issue
So request /1,2,34,56 matched by path: /ids:(\\d+[,\\d]{,*})
Link to path-to-regexp issue: https://github.com/pillarjs/path-to-regexp/issues/233