abagshaw abagshaw - 3 months ago 8
Node.js Question

expressjs get sections of url between slashes

If I setup a simple server using express for node.js listening on port

80
as follows:

app.get('/*', function (req, res) {
//mystuff
}


Imagine I trigger this function by going to
http://www.myapp.com/first/second/third


How could I get the sections of the url between the slashes and put them in some format (array of strings). So I can get
["first", "second", "third"]


Thanks!

Answer
req.url.split('/')

Some another letters to minimal 30 symbols.