New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
help: Handling parentheses in the path pattern not related prefixes #76
Comments
Understood 😄 I actually wrote most of the RAML tooling for Node.js, so I'm also aware of this. Personally, I went and implemented my own path matcher and opened a PR to the Express.js router to make it extensible in 5.0. However, that's just an FYI since you asked for the best solution, and building a custom matcher would be best (but is not really available in Express.js today until, at least, In terms of today, and if you want to continue mapping to current Express.js-compatible paths, you'll need to escape any special characters |
Is there a list of special characters? I am sure I can figure it out by code grokking but if you already know, or want to mention it for posterity. |
Sure. Of the top of my head, I believe it's Reference: https://github.com/pillarjs/path-to-regexp/blob/master/index.js#L27 |
Thanks @blakeembrey. As for my being interested in you breaking out the reusable stuff from your RAML work, I'd love to help out. I'm all for helping the community. |
@whitlockjc Most of the work come from Osprey (https://github.com/mulesoft/osprey) which mostly involved a bit of refactoring of the router (pillarjs/router#29) to support custom path handlers, at which point I wrote https://github.com/mulesoft-labs/raml-path-match. I've been meaning to correct that router and release it separately so more people can actually use it, but the PR's been around for almost a year and a half now /cc @dougwilson |
Closing this since the issue here was answered. You can escape |
I currently use
path-to-regexp
in Sway and a user reported an issue that I believe will require me to do a little escaping prior to callingpath-to-regexp
. The user is currently trying to create an OData path like/Users(:id)
but a request path of/Users(1)
does not match the regex where I would expect it to. Now, I realize the reason for this is that parentheses are special but before I just go blindly escaping/hacking this to work, I wanted to get your opinion on how best to handle this situation.Note: OpenAPI/Swagger use bracket-based variable naming in paths so in the linked issue you'll see
/Users({id})
instead of/Users(:id)
. Do not let this trip you up because I already handle converting OpenAPI/Swagger paths to Express-style paths. Also, OpenAPI/Swagger paths do not allow regex in their path pattern (in case that matters with suggesting a solution).The text was updated successfully, but these errors were encountered: