Python-like urlparser module for Javascript

I had to deconstruct and reconstruct URLs from pieces when doing advanced Javascripting for Plone.

I found this nice library from Denis Laprise. However, it had a bug with fragment extractor and lacked reconstruction possibilies. So I decided to make a new version.

Download urlparse.js version 0.2. thank you 🙂

Couple of examples:

var p = new Poly9.URLParser('');
p.getHost() == '';
p.getProtocol() == 'http';
p.getPathname() == '/pathname';
p.getQuerystring() == 'arguments=1';
p.getFragment() == 'fragment';
p.getUsername() == 'user';
p.getPassword() == 'password';

var p = new Poly9.URLParser("http://localhost:8080/path);


var url = p.getURL() // http://localhost:7070/path?foo=bar#anchor

Leave a Reply

Your email address will not be published. Required fields are marked *