Open
Description
Hi there,
Currently, if you define a route like this:
route = require('express').Router({strict: true});
route.get('/', function(req, res) {
res.send('hi');
});
And use()
that in an express application like this:
app = require('express')();
app.use('/strict/', route);
You will receive a 200 when requesting /strict/
and /strict
. I would expect only /strict/
to return a 200.
I've found an acceptable workaround by adding a check like this:
route.get('/', function(req, res, next) {
if (req.originalUrl.slice(-1) != '/') return next();
res.send('root with slash');
});
route.get('/', function(req, res) {
res.send('root without slash');
});
But I think it would be less surprising if route.get('/')
only worked for the path ending in /
when strict routing is enabled, and perhaps route.get('')
could be used for the no-slash case.