Poly9 have put together a fantastic URL parser which I’m planning to have a close look at in the not-too-distant future. It looks incredibly easy to use:

var p = new Poly9.URLParser('http://user:password@poly9.com/pathname?arguments=1#fragment');

/* OUT *
p.getHost() == 'poly9.com'
p.getProtocol() == 'http'
p.getPathname() == '/pathname'
p.getQuerystring() == 'arguments=1'
p.getFragment() == 'fragment'
p.getUsername() == 'user'
p.getPassword() == 'password'
*/

p.setURL('another.url.com');

/* OUT *
p.getHost() == 'another.url.com'
p.getProtocol() == ''
*/

p.setURL('dsdsad'); // throws an exception

You can check it out here: Poly9’s Polyvalent Javascript URL Parser

Looking at the code, it makes fantastic use of a single regular expression, with each property getting set in one go and being assigned getters and setters on the fly. An interesting way of doing things!