node.js - socket.io parse requested url
node.js, request, url
Solution
Use the URL api. http://nodejs.org/docs/latest/api/url.html
u = url.parse(url)
console.log(u.path)
Problem
I want to parse a requested url. When I used Socket.IO I had a request-object I could parse. How can I get the path from the URL? For example: ``` http://localhost:4000/foo ``` I need to extract "foo" from the URL. I've tried : ``` io.sockets.on('connection', function (socket){ console.log(socket.handshake.address.address); console.log(socket.handshake.url); } ``` But it they don't print "foo".