-
Notifications
You must be signed in to change notification settings - Fork 7
webr3/URI
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
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). Usage: var u = new URI('http://user:[email protected]/webr3/URI?query=string#this'); 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(); -> '//user:[email protected]/webr3/URI' u.heirpart().authority(); -> 'user:[email protected]' u.heirpart().authority().userinfo(); -> 'user:pass' u.heirpart().authority().host(); -> 'github.com' u.heirpart().path(); -> '/webr3/URI' u.querystring(); -> '?query=string' u.fragment(); -> '#this' Further, methods are exposed to handle complicated URIs: u = new URI('http://github.com/a/b/c/d/../.././egg#s/../x'); u.isAbsolute(); -> boolean u.defrag(); -> 'http://github.com/a/b/c/d/../.././egg' u.toAbsolute(); -> 'http://github.com/a/b/egg' and to resolve relative URIs + URI References: u = new URI('http://github.com/a/b/c/d'); u.resolveReference('../.././n?x=y'); -> 'http://github.com/a/n?x=y' node.js usage: require('./uris'); // require the file, and no, you don't need 'var uri =' var u = new URI('http://github.com/webr3/URI'); // nothing's different running the tests: URI.Test(); // be sure to include uristest first Notes: - 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: - ftp://ftp.is.co.za/rfc/rfc1808.txt - http://www.ietf.org:8080/rfc/rfc2396.txt - ldap://[2001:db8::7]:140/c=GB?objectClass?one - mailto:[email protected] - news:comp.infosystems.www.servers.unix - tel:+1-816-555-1212 - telnet://192.0.2.16/ - telnet://192.0.2.16:/ - telnet://192.0.2.16:80/ - urn:oasis:names:specification:docbook:dtd:xml:4.1.2 - svn+ssh://data.fm/opt/repos/ssl/trunk - file:///dev/null
About
ECMA-262 URI type, rfc3986 compliant, multi vendor and v8 / node.js compatible (client and server side)
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published