URL.js 
Parse and format URLs
Usage
var url = URL("https://www.duzun.me/path/index.php?var1=223#hash") ->
{
"protocol": "https:",
"username": "",
"password": "",
"host" : "www.duzun.me",
"hostname": "www.duzun.me",
"port" : "",
"pathname": "/path/index.php",
"search" : "?var1=223",
"query" : "var1=223",
"hash" : "#hash",
"path" : "/path/index.php?var1=223",
"origin" : "https://www.duzun.me",
"domain" : "duzun.me",
"href" : "https://www.duzun.me/path/index.php?var1=223#hash"
}
String(url) -> "https://www.duzun.me/path/index.php?var1=223#hash"
String( URL("new/?and=var", url) ) -> "https://www.duzun.me/path/new/?and=var"
URL.parseUrl("https://duzun.me/path/index.php", "origin") -> "https://duzun.me"
URL.parseUrl("https://duzun.me/path/index.php", "pathname") -> "/path/index.php"
URL.parseUrl("https://duzun.com/?var1=2&var2=d%27t&var3", "query", true) -> { var1: "2", var2: "d't", var3: "" }
URL.is_url('http://duzun.me') -> true
URL.is_domain('duzun.me') -> true
URL.fromObject({a:1,b:4}, "?") -> "?&a=1&b=4"
URL.toObject('a=1&b=4') -> { a: 1, b: 4 }
Note: If included in global scope with a <script>
tag,
you can var URLJS = URL.noConflict()
to restore original window.URL
and
keep using URLJS
in your module.