Sub-Folder style routing in Express
express, node.js
Solution
Use a regular expression.
app.get(/^\/((?:[^\/]+\/?)+)\//, function(req, res) {
res.send(req.params[0].split('/'));
});
app.listen(8080);
Run it and then
$ curl localhost:8080/foo/bar/baz/
["foo","bar","baz"]
Problem
I want to parse simple routes like these: ``` http://example.com/foo/bar/baz/ ``` where there is no theoretical limitation to the number of them. And it would be nice to have an array `['foo','bar','baz']` from it. How to do it with Express routing?