Poly9’s Polyvalent Javascript URL Parser
Denis Laprise and the Poly9 Group created the Polyvalent Javascript URL Parser, a very robust URL parser in JavaScript. Get the js file, the test suite or checkout the latest SVN revision with svn co https://code.poly9.com/repo/urlparser (username/password: guest/guest)
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
Poly9's, Polyvalent, Javascript, URL Parser

Leave a comment »