I have a very simple Express router and I'm trying to intercept a wildcard route that ends with !
. It looks like this:
module.exports = function (args) {
return args.express.Router()
.get(/^\/(.*)!$/, function (req, res) {
res.json('Ends with a bang! ' + req.baseUrl);
})
.get('/*', function (req, res) {
res.json('Normal path: ' + req.baseUrl);
})
};
When I request http://localhost:3000/test/abcd! I always get this response: "Normal path: /test/abcd!"
, but I was expecting the Ends with a bang!
response. Regex isn't my strong suit, but it seems so simple... what am I doing wrong?
Thanks for your help, SO community, as always.