It's worth noting that node has a URL class that can help here, rather than having to implement a regex: http://nodejs.org/api/url.html