look at json-query thing paul irish mentioned (podcast on modernizr)
Quote from java doc:
A URI is a uniform resource identifier while a URL is a uniform resource locator. Hence every URL is a URI, abstractly speaking, but not every URI is a URL. This is because there is another subcategory of URIs, uniform resource names (URNs), which name resources but do not specify how to locate them. The mailto, news, and isbn URIs shown above are examples of URNs.
var l = new Location("http://example.org");
// TypeError: Location is not a constructor
var l = Location("http://example.org");
// TypeError: Location is not a function
These are mostly having Node.js in mind:
- URL.dig() to resolve ip, reverse dns, etc.
- punycode.js - Mathias Bynens
- bestipv6.js - Rich Brown
-
http://www.whatwg.org/specs/web-apps/current-work/multipage/workers.html#workerlocation
-
MozURLProperty (not documented yet?!) https://developer.mozilla.org/User:trevorh/Interface_documentation_status
-
http://php.net/parse_str http://www.php.net/manual/en/function.http-build-query.php
For one, Firefox already used window.URL
for MozURLProperty. Modifying URLs like the following snippet just made me want to hurl (vomit, puke, throw up, …) shoot myself in the head.
var url = "http://example.org/foo?bar=baz",
separator = url.indexOf('?') > -1 ? '&' : '?';
url += separator + encodeURIComponent("foo") + "=" + encodeURIComponent("bar");
I still can't believe javascript - the f**ing backbone-language of the web - doesn't offer an API for mutating URLs in a sane way:
var url = new URL("http://example.org/foo?bar=baz");
url.addQuery("foo", "bar");
- AMD stuff
- modifiers for domain, tld, directory, file, suffix are hardly the most performant solutions
- accept all IPv6 notations
- add
bestIp6()
(for the fun of it…) - throw this at someone to make a specification out of it, so browser eventually support this natively (care to help?)