-
Notifications
You must be signed in to change notification settings - Fork 139
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
Add some sort of URI template API? #192
Comments
Couple thoughts:
|
It's not very clear to me either what a good API would look like. Wasn't a big fan of wrapping things either like the URI template "/date/{color}/{shape}/"
"/date/:color/:shape/" Would rather prefer the second option since i have been using Express.js a lot and i think it's also more readable. fyi, i just went ahead and included the sw-toolbox that had route parsing included and are based on path-to-regexp |
Note that #369 touches on this a tiny bit by defining how an external string would be encoded. https://github.com/wanderview/service-worker-scope-pattern-matching is also of interest, but that's not really about URL construction, more about matching. As for templating, seems it would be doable to build this on top of |
URI template takes care of that for you - the context is in the template operators, so that e.g., a variable in a path can be escaped correctly. The limitation that route-parser mentions is well understood; it wasn't a design goal to extract variables from a URL, and it doesn't sound like that's a goal here either. I don't see why that spec being built "on top of" 3986 makes it any less usable for your use case... |
Thanks, I misunderstood how https://tools.ietf.org/html/rfc6570 works. It does not use a parser to determine context. It seems you need to explicitly state context for the values and the result may therefore not be something that can be parsed as URL. |
It seems that |
I'm working with service workers atm and I was looking for some restful url route parser and found this: https://github.com/geraintluff/uri-templates
I didn't know there was a RFC6570 spec until now.
It would be nice to have some kind of native standard API for this.
There are many URL route parsers and I thing it is very tedious to have so many to choose from. Not every route parser is the right tool for you since it depends on Node.js or Browsers History api. You need to take the time to find something and learn something new every time since every project have some other way of solving it.
alternative solutions
https://millermedeiros.github.io/crossroads.js/
https://github.com/snd/url-pattern
https://github.com/rcs/route-parser
https://github.com/troch/path-parser
https://github.com/cowboy/javascript-route-matcher
https://github.com/evaisse/meteor-route-parser
The text was updated successfully, but these errors were encountered: