Regex as path #365
timreichen
started this conversation in
Ideas
Replies: 1 comment 2 replies
-
path-to-regex is a well established pattern/library for middleware routers like oak. The problem with plain regexs is what to do with the capturing groups, yes, some people name then, but it is far more cumbersome. When expressing a path match, it is a lot better/easier to express it as a path-to-regexp than it is a regular expression. Neither Express nor Koa routers accepts regexs for paths. In addition, is someone wants to use a regex match the path, they can just use middleware that checks the HTTP verb and/or path. The router is really intended to match structured routes. Basically I am not very keen on it. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
It would be nice to be able to specify a regex as a path. Since a string gets turned into a regex in the
Layer
constructor anyway, i think this would not break any functionality under the hood and would make the framework more expressive. I don't quite see the point in specifying a regex as a string if js has a regex API, but they also could coexist.instead of
Beta Was this translation helpful? Give feedback.
All reactions