ECMA-262 URI type, rfc3986 compliant, multi vendor and v8 / node.js compatible (client and server side)
JavaScript PHP
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


URI Type for javascript
 - Supports all kinds of URI (URL, URN, any scheme).
 - Relative URI Resolution
 - All classes extend the native String implementation.
 - Pure ECMA-262 implementation of URI spec (RFC-3986)
 - Works Client or Server side, (V8 / node.js compatible).

  var u = new URI('');
URI extends the native String implementation, so 'u' is a string, and you can call all the normal
String methods like u.indexOf(), u.match(), u.substr() and so forth.

In addition, URI exposes the following URI specific methods for reading parts of a URI (each of
which are strings themselves): 

  u.scheme();                            -> 'http:'
  u.heirpart();                          -> '//'
  u.heirpart().authority();              -> ''
  u.heirpart().authority().userinfo();   -> 'user:pass'
  u.heirpart().authority().host();       -> ''
  u.heirpart().path();                   -> '/webr3/URI'
  u.querystring();                       -> '?query=string'
  u.fragment();                          -> '#this'

Further, methods are exposed to handle complicated URIs:

  u = new URI('');
  u.isAbsolute();                        -> boolean
  u.defrag();                            -> ''
  u.toAbsolute();                        -> ''
and to resolve relative URIs + URI References:
  u = new URI(''); 
  u.resolveReference('../.././n?x=y');   -> ''

node.js usage:

  require('./uris');                              // require the file, and no, you don't need 'var uri ='
  var u = new URI(''); // nothing's different

running the tests:

  URI.Test(); // be sure to include uristest first
 - I *may* add case normalisation for segments which support it..
 - the file is called uris.js instead of uri.js because for some reason the line require('uri') makes
   v8/node throw a wobbly..
 - validation is out of scope, couldn't possibly implement validation for every scheme..

A few examples of some of the URIs supported:
 - ldap://[2001:db8::7]:140/c=GB?objectClass?one
 - news:comp.infosystems.www.servers.unix
 - tel:+1-816-555-1212
 - telnet://
 - telnet://
 - telnet://
 - urn:oasis:names:specification:docbook:dtd:xml:4.1.2
 - svn+ssh://
 - file:///dev/null