Skip to content
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

bug on route with "/" at the end #1631

Closed
carvalhoviniciusluiz opened this issue Mar 23, 2018 · 2 comments
Closed

bug on route with "/" at the end #1631

carvalhoviniciusluiz opened this issue Mar 23, 2018 · 2 comments

Comments

@carvalhoviniciusluiz
Copy link

Hello
every route with a / at the end without this passing a parameter throws a ResourceNotFound

var restify = require('restify');

function respond(req, res, next) {
  res.send('hello ' + `${req.params.name || 'nameless'}`);
  next();
}

var server = restify.createServer();
server.get('/hello/:name', respond);
server.get('/hello', respond);
server.get('/hello2/', respond); // <-- here throw ResourceNotFound

server.listen(8080, function() {
  console.log('%s listening at %s', server.name, server.url);
});

/hello and /hello2/ has the same configuration, the difference is that /hello2/ throws an exception

{
"code": "ResourceNotFound",
"message": "/hello2 does not exist"
}

this causes confusion if / is not intentional.

env

Restify Version: 7.0.0
Node.js Version: 8.9.3

@hekike
Copy link
Member

hekike commented Mar 26, 2018

ignoreTrailingSlash server option is released as v7.1.0
Thanks for reporting this!

@hekike hekike closed this as completed Mar 26, 2018
@Recodify
Copy link

Recodify commented Oct 26, 2018

This really should be enabled by default

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants