Comments (5)
Though I don't see it in the readme, the only supported tokens are those in the JavaScript "\w" set, mainly because the patterns were originally designed in Express 4 for use in JavaScript variables and properties.
I don't have an opinion on supporting the dash, only would note that it would be a breaking change in behavior (think of the route "/:lang-:country/*").
from path-to-regexp.
Thanks for responding. I'll let @theganyo read up on this since he was the original reporter and we'll go from there.
from path-to-regexp.
@whitlockjc Doug beat me to it, and this should be added to the README, but it's not supported and likely won't be.
As a side note, I don't know how you're technically handling Swagger documents and path syntax, but for RAML I implemented a custom path matcher implementation and eventually a router (since RAML does validation on URI parameters). It's likely you don't need to do that - Swagger is only Level 1 Template URIs right? (@dougwilson, this might be interesting going to back when you mentioned having a router that supported the RFC for template URIs). I couldn't find where you were actually handling the path stuff to create middleware, so this is just a brain dump of information.
Side note: I was reading through https://github.com/apigee-127/swagger-tools/blob/408e252345578716bd52b607948e287a2eb196c2/middleware/swagger-metadata.js#L327-L330 and I think it's a bug? The expressPath
never has {
since you just replaced all the instances with :
a few lines above.
from path-to-regexp.
I'm not sure why you couldn't support -
but I'm not advocating for it either. I mean, if I wanted to have a parameter named some-path
, I don't see why I couldn't have /path/:some-path
without breaking /path/:some-:path
. But again, I'm not asking for it.
As for the potential bug in swagger-tools' swagger-metadata
middleware, I do think you've found a bug and I'll report it. Speaking of Swagger, I wonder what @webron thinks about this. I wonder if there is some undocumented limitations for the variable names in Swagger path templating. Regardless, I can bring it up in swagger-tools.
Thanks a lot for looking into this.
from path-to-regexp.
Just replied to the linked topic, but for ease I'll quote it here:
The Swagger spec doesn't provide specific details about it.
However, following RFC 6570 it looks like characters other than alphanumeric or underscore cannot be used unless they are decoded. I'd leave the decision on whether to support it up to you, but I believe it's ok to not provide support for it.
For non-Swagger related tools, if you follow support for the RFC, then you probably wouldn't want to add support for it.
from path-to-regexp.
Related Issues (20)
- When parsed to tokens, why are backslashes stripped from pattern? HOT 2
- Invalid regex patterns not properly detected. HOT 2
- Another dumb question: How to run tests? HOT 2
- Erroneous test result. HOT 3
- `?` in optional capture group isn't connected to group in output - named param HOT 11
- SyntaxError: Invalid regular expression: invalid group specifier name HOT 1
- The validate config in options is not work in compile function. HOT 1
- throw new TypeError(`Unexpected ${nextType} at ${index}, expected ${type}`) HOT 3
- How about match an empty array? HOT 2
- Regex for non-negative integers only matches two or more digits HOT 1
- Return the matched path/regex
- Escaping the question mark for a query string throws and error HOT 2
- Checking if a path is a subset of another path HOT 1
- params are being joined without `/` HOT 1
- Issue with converted value used in Next.js rewrite HOT 3
- Contributing named capture groups to pathToRegexp HOT 10
- Expected "id" to be a string error with release 7.0.0 HOT 3
- Error on vite build of TypeScript Vue3 project: "match" is not exported HOT 3
- pathToRegexp not exported in v7.1.0 HOT 1
- Non greedy repeats seem currently impossible HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from path-to-regexp.