Skip to content

donyahelwa/URI.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

URL.js

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. 

Browsers suck

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

Nice to have…

These are mostly having Node.js in mind:

  • URL.dig() to resolve ip, reverse dns, etc.

Contains Code From

Resources

Why name it hURL?

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");

TODO

  • 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?)

About

Javascript URL mutation library

Resources

Stars

Watchers

Forks

Packages

No packages published