JavaScript URI/URL object

grink on 2008-09-11T23:21:11

I've put together an interactive example of my JavaScript URI object:

b9j.uri.URI example

The example will also show the code necessary to perform the given operation (next to the result)

b9j.uri.URI overview:

  • Parses using Steven Levithan's parseUri 1.2
  • Easy path traversal (ascend to parent, descend to a child)
  • Set or add to the URI query (with proper encoding), get/interrogate the query (with proper decoding)
  • Add arbitrary data (unencoded) to the end of the query string, for extra flexibility
  • Manipulate/interrogate the scheme, user information (username & password), host, port, fragment, and more in a piecewise fashion
  • Add, change or strip the extension (html, js, css, ...) from a given URI

The code is available at http://appengine.bravo9.com/b9j/b9j.uri.js (19kb compressed / 5kb gzipped)

See also the documentation for b9j.uri

Screenshot of the interactive b9j.uri.URI example

JavaScript URI object