Following my b9j.path release, I just finished up work on URI object-class for javascript.
It uses Steven Levithan's parseUri 1.2 to do the parsing.
Some example usage:
var uri = new b9j.uri.URI( "http://example.com/a/b?a=1&b=2&c=3&c=4&c=5" )
var host = uri.host()
var child = uri.child("c.html") // http://example.com/a/b/c.html?a=1&b=2& ...
child.query().add({ c: [ 6, 7 ], d: 8 }) // ... ?a=1&b=2&c=3&c=4&c=5&c=6&c=7&d=8
child.query().set("b", 9) // ... ?a=1&b=9&c ...
return child.toString()
Again, while CPAN has URI.pm for URI-handling, JavaScript didn't really have an equivalent (parsing yes -- modifying/generating no).
Re:js-uri
grink on 2008-09-11T23:40:59
Yeah, I saw that while doing some research. Looked like a good crack at URI parsing, but ultimately I went with Steven Levithan's parseUri:
http://blog.stevenlevithan.com/archives/parseuri
My take was an exercise in wrapping the parser and providing methods to access/update the path, query, etc.
I've put up an interactive example here (which will show you the code at the same time):