Giter VIP home page Giter VIP logo

Comments (6)

blakeembrey avatar blakeembrey commented on July 24, 2024 2

Closing this since the issue here was answered. You can escape path-to-regexp special characters with \\.

from path-to-regexp.

blakeembrey avatar blakeembrey commented on July 24, 2024 1

@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

from path-to-regexp.

blakeembrey avatar blakeembrey commented on July 24, 2024

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, [email protected] is released). Would you be interested in using this approach? (I wouldn't mind spending some time exposing this work for you to re-use, I can also link to anything RAML-related which solved the same problems).

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 path-to-regexp has. Just be aware that although the current path-to-regexp is 1.x and has a lot of improved features, current Express.js uses 0.1.x and has a few quirks when it comes to matching.

from path-to-regexp.

whitlockjc avatar whitlockjc commented on July 24, 2024

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.

from path-to-regexp.

blakeembrey avatar blakeembrey commented on July 24, 2024

Sure. Of the top of my head, I believe it's (, ), :, *, + and ?.

Reference: https://github.com/pillarjs/path-to-regexp/blob/master/index.js#L27

from path-to-regexp.

whitlockjc avatar whitlockjc commented on July 24, 2024

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.

from path-to-regexp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.