restify / restify/node-restify
Documentation to support route with colon
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 10.7k
- Forks
- 975
- Avg merge
- 1d 6h
- Merged PRs (30d)
- 5
Description
Feature Request
The documentation covers routes very well, but it does not cover some of the exceptional cases. For example when setting up a route the character colon has special meaning. As such if I use colon in the route it changes the URL handled by that route. So how do we make a route that handles a URL with a literal colon in it?
Use Case
A couple API end points
- GET /hello:bob
- GET /hello:name=bob
- GET /hello:full-name=bob%20smith
I want to setup a route that will handle these requests:
function respondName(req, res, next) {
res.send('hello ' + req.params.name);
next();
}
I could try this:
server.get('/hello:name', respond);
How ever now the program will output:
hello :bob
It has the colon embedded in the argument.
Now when I try to escape it, there is no documentation how. Which of the following would allow a colon to appear in the URL.
Use slash escape:
server.get('/hello\::name', respond);
Regex literal
server.get('/hello[:]:name', respond);
Percent encoding:
server.get('/hello%3A:name', respond);
Regex object:
server.get(/^\/hello:[^:]+/, respond);
Repeat special character:
server.get('/hello::name', respond);
Repeat special character twice:
server.get('/hello:::name', respond);
We have URLs that have colons and identifiers in them. We are trying to upgrade to the latest restify
Are you willing and able to implement this?
We could help update the documentation regarding this, but need to know how it should be done.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the existing route documentation and the routing behavior for colon-containing paths. Use the examples in this issue to determine which form handles a literal colon and preserves the named parameter, then document that form and verify the resulting requests are covered clearly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100