Via Ajaxian redescubro URLParser, una librería JS que se encarga de ayudarnos a parsear una URL. Realmente potente y cómoda de usar.
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() == ''
*/
0 comentarios, 1 referencias
+
#