Express: Optional trailing slash for top-level path
I know this is an old question, but I had the same issue and I came up with this:
app.get(['/foo', '/foo/*'], ...);
This will match /foo
, /foo/
, and anything under /foo/...
. I think this is a more readable solution than a regular expression and it communicates clearly what is intended.