PR that fixes documentation regarding RegExps in paths has not been merged
- [x] Used appropriate template for the issue type
- [x] Searched both open and closed issues for duplicates of this issue
- [x] Title adequately and concisely reflects the bug
Bug Report
Restify Version
current 7.2.3
Node.js Version
not applicable
Expected behaviour
- The docs should fit the current behaviour/state.
- Work in PR #1679 should be merged into master.
- The docs should clearly explain how RegExp chunks now work
- The updated docs should be live on restify.com/docs
Actual behaviour
Documentation is out of date: http://restify.com/docs/server-api/#servermethodopts states:
Types Server~methodOpts Server method opts Type: (String | Regexp | Object)
(emphasis mine)
Suggestion
The last line should probably be:
Type: (String | Object)
Additionally, it would be nice if the possibilities to use RegExps would be explained in more detail, e.g. I'm wondering whether that ^\ prefix is always necessary (to me it doesn't make sense in the example). Or at least link to https://github.com/delvedor/find-my-way#supported-path-formats
Related issues and PRs
This problem was already addressed in issue #1644, but the issue was auto-closed because it was stale. The same happened to PR #1679 that should've closed the issue, but was never merged.
Are you able to fix this?
No, because I don't have the permission to merge that PR and because I don't know if that PR already completely fixes the docs entirely.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
I am not able to fix this, and I'm not 100% aware of the current situation within the docs and the code, but I think that the docs are still not outlining the actual situation correctly. So may I make another attempt of bringing this issue to someone's attention?
@christophfriedrich Sure, I can take a look at this.
Thanks @rajatkumar for stepping up! :+1: Did you find anything so far? :-)
This is still an issue. The documentation still claims in multiple places that you can use RegExp objects in the server methods. This has caused myself and restify package developers plenty of confusion.
Example 1 (http://restify.com/docs/home/#routing):
You can also pass in a RegExp object and access the capture group with req.params (which will not be interpreted in any way):
server.get(/^\/([a-zA-Z0-9_\.~-]+)\/(.*)/, function(req, res, next) {
console.log(req.params[0]);
console.log(req.params[1]);
res.send(200);
return next();
});
Example 2 (http://restify.com/docs/server-api/#servermethodopts):
Server~methodOpts
Server method opts
Type: (String | Regexp | Object)
Is anyone available who can fix this?