diff --git a/package.json b/package.json index 0658699..2b42e1d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "js-url", - "version": "2.0.1", + "version": "2.0.2", "description": "A simple, lightweight url parser for JavaScript (~1.7 Kb minified, ~0.7Kb gzipped).", "main": "url.js", "repository": { diff --git a/tests.js b/tests.js index 156d6e1..e9a4c38 100644 --- a/tests.js +++ b/tests.js @@ -86,6 +86,15 @@ else { }); } +test('mailto', function() { + deepEqual( window.url( 'email', 'mailto:rob@websanova.com' ), 'rob@websanova.com' ); + deepEqual( window.url( 'protocol', 'mailto:rob@websanova.com' ), 'mailto' ); + deepEqual( window.url( 'email', 'mailto:/rob@websanova.com' ), undefined ); + deepEqual( window.url( 'email', 'mailto://rob@websanova.com' ), undefined ); + deepEqual( window.url( 'protocol', 'mailto:/rob@websanova.com' ), 'http' ); + deepEqual( window.url( 'mailto:', 'mailto:/rob@websanova.com' ), undefined ); +}); + test('hostname', function() { deepEqual( window.url( 'hostname', url ), 'www.domain.com' ); deepEqual( window.url( 'hostname', urlIp ), '1.2.3.4' ); @@ -101,14 +110,7 @@ test('domain parts', function() { test('auth', function() { deepEqual( window.url( 'auth', url ), 'rob:abcd1234' ); -}); - -test('user', function() { deepEqual( window.url( 'user', url ), 'rob' ); - deepEqual( window.url( 'email', 'mailto:rob@websanova.com' ), 'rob@websanova.com' ); -}); - -test('pass', function() { deepEqual( window.url( 'pass', url ), 'abcd1234' ); }); @@ -124,6 +126,7 @@ test('port', function() { deepEqual( window.url( 'port', 'http://domain.com:443' ), '443' ); deepEqual( window.url( 'port', 'http://domain.com' ), '80' ); deepEqual( window.url( 'port', 'https://domain.com' ), '443' ); + deepEqual( window.url( 'port', 'rob@domain.com' ), '80' ); }); test('protocol', function() { @@ -135,7 +138,7 @@ test('protocol', function() { deepEqual( window.url( 'protocol', 'domain.com:443' ), 'https' ); deepEqual( window.url( 'protocol', 'https://domain.com:443' ), 'https' ); deepEqual( window.url( 'protocol', 'https://domain.com:80' ), 'https' ); - deepEqual( window.url( 'protocol', 'mailto:rob@websanova.com' ), 'mailto' ); + deepEqual( window.url( 'protocol', 'rob@domain.com' ), 'http' ); }); test('path', function() { @@ -166,6 +169,9 @@ test('file', function() { deepEqual( window.url( 'file', url ), 'index.html' ); deepEqual( window.url( 'filename', url ), 'index' ); deepEqual( window.url( 'fileext', url ), 'html' ); + deepEqual( window.url( 'file', 'http://domain.com' ), undefined ); + deepEqual( window.url( 'filename', 'http://domain.com' ), undefined ); + deepEqual( window.url( 'fileext', 'http://domain.com' ), undefined ); }); test('url parts', function() { @@ -198,6 +204,8 @@ test('query string', function() { deepEqual( window.url( '?key', 'http://domain.com?key=value=va?key2=value' ), 'value=va?key2=value'); deepEqual( window.url( '?poo', 'http://domain.com:400?poo=a:b' ), 'a:b' ); deepEqual( window.url( '?poo', 'http://domain.com:400? & & &' ), undefined ); + deepEqual( window.url( '?test', 'http://domain.com?test=45#5' ), '45' ); + deepEqual( window.url( '?test', 'http://domain.com?test=45?5' ), '45?5' ); deepEqual( window.url( '?field[0]', 'http://domain.com?field[0]=zero&firled[1]=one' ), 'zero' ); deepEqual( window.url( '?field', 'http://domain.com?field[0]=zero&field[1]=one&var=test' ), ['zero', 'one'] ); @@ -216,6 +224,7 @@ test('hash string', function() { deepEqual( window.url( '#poo', 'http://domain.com#poo' ), '' ); deepEqual( window.url( '#poo', 'http://domain.com#' ), undefined ); deepEqual( window.url( '#poo', 'http://domain.com' ), undefined ); + deepEqual( window.url( '#test', 'http://domain.com#test=45#5' ), '45#5' ); deepEqual( window.url( '#field[0]', 'http://domain.com#field[0]=zero&firled[1]=one' ), 'zero' ); deepEqual( window.url( '#field', 'http://domain.com#field[0]=zero&field[1]=one&var=test' ), ['zero', 'one'] ); diff --git a/url-tld.min.js b/url-tld.min.js index ce0c13e..47e4970 100644 --- a/url-tld.min.js +++ b/url-tld.min.js @@ -1 +1 @@ -/*! url - v2.0.1 - 2015-09-06 */window.url=function(){function a(){return new RegExp(/(.*?)\.?([^\.]*?)\.?(com|net|org|biz|ws|in|me|co\.uk|co|org\.uk|ltd\.uk|plc\.uk|me\.uk|edu|mil|br\.com|cn\.com|eu\.com|hu\.com|no\.com|qc\.com|sa\.com|se\.com|se\.net|us\.com|uy\.com|ac|co\.ac|gv\.ac|or\.ac|ac\.ac|af|am|as|at|ac\.at|co\.at|gv\.at|or\.at|asn\.au|com\.au|edu\.au|org\.au|net\.au|id\.au|be|ac\.be|adm\.br|adv\.br|am\.br|arq\.br|art\.br|bio\.br|cng\.br|cnt\.br|com\.br|ecn\.br|eng\.br|esp\.br|etc\.br|eti\.br|fm\.br|fot\.br|fst\.br|g12\.br|gov\.br|ind\.br|inf\.br|jor\.br|lel\.br|med\.br|mil\.br|net\.br|nom\.br|ntr\.br|odo\.br|org\.br|ppg\.br|pro\.br|psc\.br|psi\.br|rec\.br|slg\.br|tmp\.br|tur\.br|tv\.br|vet\.br|zlg\.br|br|ab\.ca|bc\.ca|mb\.ca|nb\.ca|nf\.ca|ns\.ca|nt\.ca|on\.ca|pe\.ca|qc\.ca|sk\.ca|yk\.ca|ca|cc|ac\.cn|com\.cn|edu\.cn|gov\.cn|org\.cn|bj\.cn|sh\.cn|tj\.cn|cq\.cn|he\.cn|nm\.cn|ln\.cn|jl\.cn|hl\.cn|js\.cn|zj\.cn|ah\.cn|gd\.cn|gx\.cn|hi\.cn|sc\.cn|gz\.cn|yn\.cn|xz\.cn|sn\.cn|gs\.cn|qh\.cn|nx\.cn|xj\.cn|tw\.cn|hk\.cn|mo\.cn|cn|cx|cz|de|dk|fo|com\.ec|tm\.fr|com\.fr|asso\.fr|presse\.fr|fr|gf|gs|co\.il|net\.il|ac\.il|k12\.il|gov\.il|muni\.il|ac\.in|co\.in|org\.in|ernet\.in|gov\.in|net\.in|res\.in|is|it|ac\.jp|co\.jp|go\.jp|or\.jp|ne\.jp|ac\.kr|co\.kr|go\.kr|ne\.kr|nm\.kr|or\.kr|li|lt|lu|asso\.mc|tm\.mc|com\.mm|org\.mm|net\.mm|edu\.mm|gov\.mm|ms|nl|no|nu|pl|ro|org\.ro|store\.ro|tm\.ro|firm\.ro|www\.ro|arts\.ro|rec\.ro|info\.ro|nom\.ro|nt\.ro|se|si|com\.sg|org\.sg|net\.sg|gov\.sg|sk|st|tf|ac\.th|co\.th|go\.th|mi\.th|net\.th|or\.th|tm|to|com\.tr|edu\.tr|gov\.tr|k12\.tr|net\.tr|org\.tr|com\.tw|org\.tw|net\.tw|ac\.uk|uk\.com|uk\.net|gb\.com|gb\.net|vg|sh|kz|ch|info|ua|gov|name|pro|ie|hk|com\.hk|org\.hk|net\.hk|edu\.hk|us|tk|cd|by|ad|lv|eu\.lv|bz|es|jp|cl|ag|mobi|eu|co\.nz|org\.nz|net\.nz|maori\.nz|iwi\.nz|io|la|md|sc|sg|vc|tw|travel|my|se|tv|pt|com\.pt|edu\.pt|asia|fi|com\.ve|net\.ve|fi|org\.ve|web\.ve|info\.ve|co\.ve|tel|im|gr|ru|net\.ru|org\.ru|hr|com\.hr|ly|xyz)$/)}function b(a){return decodeURIComponent(a.replace(/\+/g," "))}function c(a,b){var c=a.charAt(0),d=b.split(c);return c===a?d:(a=parseInt(a.substring(1),10),d[0>a?d.length+a:a-1])}function d(a,c){var d=a.charAt(0),e=c.split("&"),f=[],g={},h=[],i=a.substring(1);for(var j in e)if(f=e[j].split(/=(.*)/),""!==f[0].replace(/\s/g,"")){if(f[1]=b(f[1]||""),i===f[0])return f[1];h=f[0].match(/(.*)\[([0-9]+)\]/),h?(g[h[1]]=g[h[1]]||[],g[h[1]][h[2]]=f[1]):g[f[0]]=f[1]}return d===a?g:g[i]}return function(b,e){var f,g,h={};if("tld?"===b)return a();if(e=e||window.location.toString(),!b)return e;if(b=b.toString(),e.match(/^mailto:[^\/]/))h.protocol="mailto",h.email=e.split(/mailto\:/)[1];else{if(f=e.split(/#(.*)/),h.hash=f[1]?f[1]:void 0,h.hash&&b.match(/^#/))return d(b,h.hash);if(f=f[0].split(/\?(.*)/),h.query=f[1]?f[1]:void 0,h.query&&b.match(/^\?/))return d(b,h.query);if(f=f[0].split(/\:?\/\//),h.protocol=f[1]?f[0].toLowerCase():void 0,f=(f[1]?f[1]:f[0]).split(/(\/.*)/),h.path=f[1]?f[1]:"",h.path=h.path.replace(/^([^\/])/,"/$1").replace(/\/$/,""),b.match(/^[\-0-9]+$/)&&(b=b.replace(/^([^\/])/,"/$1")),b.match(/^\//))return c(b,h.path.substring(1));if(g=c("/-1",h.path.substring(1)),g=g.split(/\.(.*)/),g[1]&&(h.file=g[0]+"."+g[1],h.filename=g[0],h.fileext=g[1]),f=f[0].split(/\:([0-9]+)$/),h.port=f[1]?f[1]:void 0,f=f[0].split(/@/),h.auth=f[1]?f[0]:void 0,h.auth&&(g=h.auth.split(/\:(.*)/),h.user=g[0],h.pass=g[1]),h.hostname=(f[1]?f[1]:f[0]).toLowerCase(),"."===b.charAt(0))return c(b,h.hostname);a()&&(f=h.hostname.match(a()),f&&(h.tld=f[3],h.domain=f[2]?f[2]+"."+f[3]:void 0,h.sub=f[1]||void 0)),h.port=h.port||("https"===h.protocol?"443":"80"),h.protocol=h.protocol||("443"===h.port?"https":"http")}return b in h?h[b]:"[]"===b?h:void 0}}(),"undefined"!=typeof jQuery&&jQuery.extend({url:function(a,b){return window.url(a,b)}}); \ No newline at end of file +/*! js-url - v2.0.2 - 2015-09-17 */window.url=function(){function a(){return new RegExp(/(.*?)\.?([^\.]*?)\.?(com|net|org|biz|ws|in|me|co\.uk|co|org\.uk|ltd\.uk|plc\.uk|me\.uk|edu|mil|br\.com|cn\.com|eu\.com|hu\.com|no\.com|qc\.com|sa\.com|se\.com|se\.net|us\.com|uy\.com|ac|co\.ac|gv\.ac|or\.ac|ac\.ac|af|am|as|at|ac\.at|co\.at|gv\.at|or\.at|asn\.au|com\.au|edu\.au|org\.au|net\.au|id\.au|be|ac\.be|adm\.br|adv\.br|am\.br|arq\.br|art\.br|bio\.br|cng\.br|cnt\.br|com\.br|ecn\.br|eng\.br|esp\.br|etc\.br|eti\.br|fm\.br|fot\.br|fst\.br|g12\.br|gov\.br|ind\.br|inf\.br|jor\.br|lel\.br|med\.br|mil\.br|net\.br|nom\.br|ntr\.br|odo\.br|org\.br|ppg\.br|pro\.br|psc\.br|psi\.br|rec\.br|slg\.br|tmp\.br|tur\.br|tv\.br|vet\.br|zlg\.br|br|ab\.ca|bc\.ca|mb\.ca|nb\.ca|nf\.ca|ns\.ca|nt\.ca|on\.ca|pe\.ca|qc\.ca|sk\.ca|yk\.ca|ca|cc|ac\.cn|com\.cn|edu\.cn|gov\.cn|org\.cn|bj\.cn|sh\.cn|tj\.cn|cq\.cn|he\.cn|nm\.cn|ln\.cn|jl\.cn|hl\.cn|js\.cn|zj\.cn|ah\.cn|gd\.cn|gx\.cn|hi\.cn|sc\.cn|gz\.cn|yn\.cn|xz\.cn|sn\.cn|gs\.cn|qh\.cn|nx\.cn|xj\.cn|tw\.cn|hk\.cn|mo\.cn|cn|cx|cz|de|dk|fo|com\.ec|tm\.fr|com\.fr|asso\.fr|presse\.fr|fr|gf|gs|co\.il|net\.il|ac\.il|k12\.il|gov\.il|muni\.il|ac\.in|co\.in|org\.in|ernet\.in|gov\.in|net\.in|res\.in|is|it|ac\.jp|co\.jp|go\.jp|or\.jp|ne\.jp|ac\.kr|co\.kr|go\.kr|ne\.kr|nm\.kr|or\.kr|li|lt|lu|asso\.mc|tm\.mc|com\.mm|org\.mm|net\.mm|edu\.mm|gov\.mm|ms|nl|no|nu|pl|ro|org\.ro|store\.ro|tm\.ro|firm\.ro|www\.ro|arts\.ro|rec\.ro|info\.ro|nom\.ro|nt\.ro|se|si|com\.sg|org\.sg|net\.sg|gov\.sg|sk|st|tf|ac\.th|co\.th|go\.th|mi\.th|net\.th|or\.th|tm|to|com\.tr|edu\.tr|gov\.tr|k12\.tr|net\.tr|org\.tr|com\.tw|org\.tw|net\.tw|ac\.uk|uk\.com|uk\.net|gb\.com|gb\.net|vg|sh|kz|ch|info|ua|gov|name|pro|ie|hk|com\.hk|org\.hk|net\.hk|edu\.hk|us|tk|cd|by|ad|lv|eu\.lv|bz|es|jp|cl|ag|mobi|eu|co\.nz|org\.nz|net\.nz|maori\.nz|iwi\.nz|io|la|md|sc|sg|vc|tw|travel|my|se|tv|pt|com\.pt|edu\.pt|asia|fi|com\.ve|net\.ve|fi|org\.ve|web\.ve|info\.ve|co\.ve|tel|im|gr|ru|net\.ru|org\.ru|hr|com\.hr|ly|xyz)$/)}function b(a){return decodeURIComponent(a.replace(/\+/g," "))}function c(a,b){var c=a.charAt(0),d=b.split(c);return c===a?d:(a=parseInt(a.substring(1),10),d[0>a?d.length+a:a-1])}function d(a,c){var d=a.charAt(0),e=c.split("&"),f=[],g={},h=[],i=a.substring(1);for(var j in e)if(f=e[j].match(/(.*?)=(.*)/),f||(f=[e[j],e[j],""]),""!==f[1].replace(/\s/g,"")){if(f[2]=b(f[2]||""),i===f[1])return f[2];h=f[1].match(/(.*)\[([0-9]+)\]/),h?(g[h[1]]=g[h[1]]||[],g[h[1]][h[2]]=f[2]):g[f[1]]=f[2]}return d===a?g:g[i]}return function(b,e){var f,g={};if("tld?"===b)return a();if(e=e||window.location.toString(),!b)return e;if(b=b.toString(),f=e.match(/^mailto:([^\/].+)/))g.protocol="mailto",g.email=f[1];else{if((f=e.match(/(.*?)#(.*)/))&&(g.hash=f[2],e=f[1]),g.hash&&b.match(/^#/))return d(b,g.hash);if((f=e.match(/(.*?)\?(.*)/))&&(g.query=f[2],e=f[1]),g.query&&b.match(/^\?/))return d(b,g.query);if((f=e.match(/(.*?)\:?\/\/(.*)/))&&(g.protocol=f[1].toLowerCase(),e=f[2]),(f=e.match(/(.*?)(\/.*)/))&&(g.path=f[2],e=f[1]),g.path=(g.path||"").replace(/^([^\/])/,"/$1").replace(/\/$/,""),b.match(/^[\-0-9]+$/)&&(b=b.replace(/^([^\/])/,"/$1")),b.match(/^\//))return c(b,g.path.substring(1));if(f=c("/-1",g.path.substring(1)),f&&(f=f.match(/(.*?)\.(.*)/))&&(g.file=f[0],g.filename=f[1],g.fileext=f[2]),(f=e.match(/(.*)\:([0-9]+)$/))&&(g.port=f[2],e=f[1]),(f=e.match(/(.*?)@(.*)/))&&(g.auth=f[1],e=f[2]),g.auth&&(f=g.auth.match(/(.*)\:(.*)/),g.user=f?f[1]:g.auth,g.pass=f?f[2]:void 0),g.hostname=e.toLowerCase(),"."===b.charAt(0))return c(b,g.hostname);a()&&(f=g.hostname.match(a()),f&&(g.tld=f[3],g.domain=f[2]?f[2]+"."+f[3]:void 0,g.sub=f[1]||void 0)),g.port=g.port||("https"===g.protocol?"443":"80"),g.protocol=g.protocol||("443"===g.port?"https":"http")}return b in g?g[b]:"[]"===b?g:void 0}}(),"undefined"!=typeof jQuery&&jQuery.extend({url:function(a,b){return window.url(a,b)}}); \ No newline at end of file diff --git a/url.jquery.json b/url.jquery.json index 0a1abc6..fcfa96e 100644 --- a/url.jquery.json +++ b/url.jquery.json @@ -6,7 +6,7 @@ "websanova", "url" ], - "version": "2.0.1", + "version": "2.0.2", "author": { "name": "Websanova", "email": "rob@websanova.com", diff --git a/url.js b/url.js index daa7330..8d475b5 100644 --- a/url.js +++ b/url.js @@ -28,24 +28,29 @@ window.url = (function() { arg2 = arg.substring(1); for (var i in split) { - field = split[i].split(/=(.*)/); + field = split[i].match(/(.*?)=(.*)/); - if (field[0].replace(/\s/g, '') !== '') { - field[1] = _d(field[1] || ''); + // TODO: regex should be able to handle this. + if ( ! field) { + field = [split[i], split[i], '']; + } + + if (field[1].replace(/\s/g, '') !== '') { + field[2] = _d(field[2] || ''); // If we have a match just return it right away. - if (arg2 === field[0]) { return field[1]; } + if (arg2 === field[1]) { return field[2]; } // Check for array pattern. - tmp = field[0].match(/(.*)\[([0-9]+)\]/); + tmp = field[1].match(/(.*)\[([0-9]+)\]/); if (tmp) { params[tmp[1]] = params[tmp[1]] || []; - params[tmp[1]][tmp[2]] = field[1]; + params[tmp[1]][tmp[2]] = field[2]; } else { - params[field[0]] = field[1]; + params[field[1]] = field[2]; } } } @@ -66,69 +71,80 @@ window.url = (function() { arg = arg.toString(); - if (url.match(/^mailto:[^\/]/)) { + if (tmp = url.match(/^mailto:([^\/].+)/)) { _l.protocol = 'mailto'; - _l.email = url.split(/mailto\:/)[1]; + _l.email = tmp[1]; } else { - // Anchor. - tmp = url.split(/#(.*)/); - _l.hash = tmp[1] ? tmp[1] : undefined; + // Hash. + if (tmp = url.match(/(.*?)#(.*)/)) { + _l.hash = tmp[2]; + url = tmp[1]; + } - // Return anchor parts. + // Return hash parts. if (_l.hash && arg.match(/^#/)) { return _f(arg, _l.hash); } - + // Query - tmp = tmp[0].split(/\?(.*)/); - _l.query = tmp[1] ? tmp[1] : undefined; + if (tmp = url.match(/(.*?)\?(.*)/)) { + _l.query = tmp[2]; + url = tmp[1]; + } // Return query parts. if (_l.query && arg.match(/^\?/)) { return _f(arg, _l.query); } // Protocol. - tmp = tmp[0].split(/\:?\/\//); - _l.protocol = tmp[1] ? tmp[0].toLowerCase() : undefined; + if (tmp = url.match(/(.*?)\:?\/\/(.*)/)) { + _l.protocol = tmp[1].toLowerCase(); + url = tmp[2]; + } // Path. - tmp = (tmp[1] ? tmp[1] : tmp[0]).split(/(\/.*)/); - _l.path = tmp[1] ? tmp[1] : ''; + if (tmp = url.match(/(.*?)(\/.*)/)) { + _l.path = tmp[2]; + url = tmp[1]; + } // Clean up path. - _l.path = _l.path.replace(/^([^\/])/, '/$1').replace(/\/$/, ''); + _l.path = (_l.path || '').replace(/^([^\/])/, '/$1').replace(/\/$/, ''); // Return path parts. if (arg.match(/^[\-0-9]+$/)) { arg = arg.replace(/^([^\/])/, '/$1'); } if (arg.match(/^\//)) { return _i(arg, _l.path.substring(1)); } // File. - tmp2 = _i('/-1', _l.path.substring(1)); - tmp2 = tmp2.split(/\.(.*)/); - - // Filename and fileext. - if (tmp2[1]) { - _l.file = tmp2[0] + '.' + tmp2[1]; - _l.filename = tmp2[0]; - _l.fileext = tmp2[1]; + tmp = _i('/-1', _l.path.substring(1)); + + if (tmp && (tmp = tmp.match(/(.*?)\.(.*)/))) { + _l.file = tmp[0]; + _l.filename = tmp[1]; + _l.fileext = tmp[2]; } // Port. - tmp = tmp[0].split(/\:([0-9]+)$/); - _l.port = tmp[1] ? tmp[1] : undefined; + if (tmp = url.match(/(.*)\:([0-9]+)$/)) { + _l.port = tmp[2]; + url = tmp[1]; + } // Auth. - tmp = tmp[0].split(/@/); - _l.auth = tmp[1] ? tmp[0] : undefined; + if (tmp = url.match(/(.*?)@(.*)/)) { + _l.auth = tmp[1]; + url = tmp[2]; + } // User and pass. if (_l.auth) { - tmp2 = _l.auth.split(/\:(.*)/); - _l.user = tmp2[0]; - _l.pass = tmp2[1]; + tmp = _l.auth.match(/(.*)\:(.*)/); + + _l.user = tmp ? tmp[1] : _l.auth; + _l.pass = tmp ? tmp[2] : undefined; } // Hostname. - _l.hostname = (tmp[1] ? tmp[1] : tmp[0]).toLowerCase(); + _l.hostname = url.toLowerCase(); // Return hostname parts. if (arg.charAt(0) === '.') { return _i(arg, _l.hostname); } diff --git a/url.min.js b/url.min.js index ebe7379..4ca6320 100644 --- a/url.min.js +++ b/url.min.js @@ -1 +1 @@ -/*! url - v2.0.1 - 2015-09-06 */window.url=function(){function a(){}function b(a){return decodeURIComponent(a.replace(/\+/g," "))}function c(a,b){var c=a.charAt(0),d=b.split(c);return c===a?d:(a=parseInt(a.substring(1),10),d[0>a?d.length+a:a-1])}function d(a,c){var d=a.charAt(0),e=c.split("&"),f=[],g={},h=[],i=a.substring(1);for(var j in e)if(f=e[j].split(/=(.*)/),""!==f[0].replace(/\s/g,"")){if(f[1]=b(f[1]||""),i===f[0])return f[1];h=f[0].match(/(.*)\[([0-9]+)\]/),h?(g[h[1]]=g[h[1]]||[],g[h[1]][h[2]]=f[1]):g[f[0]]=f[1]}return d===a?g:g[i]}return function(b,e){var f,g,h={};if("tld?"===b)return a();if(e=e||window.location.toString(),!b)return e;if(b=b.toString(),e.match(/^mailto:[^\/]/))h.protocol="mailto",h.email=e.split(/mailto\:/)[1];else{if(f=e.split(/#(.*)/),h.hash=f[1]?f[1]:void 0,h.hash&&b.match(/^#/))return d(b,h.hash);if(f=f[0].split(/\?(.*)/),h.query=f[1]?f[1]:void 0,h.query&&b.match(/^\?/))return d(b,h.query);if(f=f[0].split(/\:?\/\//),h.protocol=f[1]?f[0].toLowerCase():void 0,f=(f[1]?f[1]:f[0]).split(/(\/.*)/),h.path=f[1]?f[1]:"",h.path=h.path.replace(/^([^\/])/,"/$1").replace(/\/$/,""),b.match(/^[\-0-9]+$/)&&(b=b.replace(/^([^\/])/,"/$1")),b.match(/^\//))return c(b,h.path.substring(1));if(g=c("/-1",h.path.substring(1)),g=g.split(/\.(.*)/),g[1]&&(h.file=g[0]+"."+g[1],h.filename=g[0],h.fileext=g[1]),f=f[0].split(/\:([0-9]+)$/),h.port=f[1]?f[1]:void 0,f=f[0].split(/@/),h.auth=f[1]?f[0]:void 0,h.auth&&(g=h.auth.split(/\:(.*)/),h.user=g[0],h.pass=g[1]),h.hostname=(f[1]?f[1]:f[0]).toLowerCase(),"."===b.charAt(0))return c(b,h.hostname);a()&&(f=h.hostname.match(a()),f&&(h.tld=f[3],h.domain=f[2]?f[2]+"."+f[3]:void 0,h.sub=f[1]||void 0)),h.port=h.port||("https"===h.protocol?"443":"80"),h.protocol=h.protocol||("443"===h.port?"https":"http")}return b in h?h[b]:"[]"===b?h:void 0}}(),"undefined"!=typeof jQuery&&jQuery.extend({url:function(a,b){return window.url(a,b)}}); \ No newline at end of file +/*! js-url - v2.0.2 - 2015-09-17 */window.url=function(){function a(){}function b(a){return decodeURIComponent(a.replace(/\+/g," "))}function c(a,b){var c=a.charAt(0),d=b.split(c);return c===a?d:(a=parseInt(a.substring(1),10),d[0>a?d.length+a:a-1])}function d(a,c){var d=a.charAt(0),e=c.split("&"),f=[],g={},h=[],i=a.substring(1);for(var j in e)if(f=e[j].match(/(.*?)=(.*)/),f||(f=[e[j],e[j],""]),""!==f[1].replace(/\s/g,"")){if(f[2]=b(f[2]||""),i===f[1])return f[2];h=f[1].match(/(.*)\[([0-9]+)\]/),h?(g[h[1]]=g[h[1]]||[],g[h[1]][h[2]]=f[2]):g[f[1]]=f[2]}return d===a?g:g[i]}return function(b,e){var f,g={};if("tld?"===b)return a();if(e=e||window.location.toString(),!b)return e;if(b=b.toString(),f=e.match(/^mailto:([^\/].+)/))g.protocol="mailto",g.email=f[1];else{if((f=e.match(/(.*?)#(.*)/))&&(g.hash=f[2],e=f[1]),g.hash&&b.match(/^#/))return d(b,g.hash);if((f=e.match(/(.*?)\?(.*)/))&&(g.query=f[2],e=f[1]),g.query&&b.match(/^\?/))return d(b,g.query);if((f=e.match(/(.*?)\:?\/\/(.*)/))&&(g.protocol=f[1].toLowerCase(),e=f[2]),(f=e.match(/(.*?)(\/.*)/))&&(g.path=f[2],e=f[1]),g.path=(g.path||"").replace(/^([^\/])/,"/$1").replace(/\/$/,""),b.match(/^[\-0-9]+$/)&&(b=b.replace(/^([^\/])/,"/$1")),b.match(/^\//))return c(b,g.path.substring(1));if(f=c("/-1",g.path.substring(1)),f&&(f=f.match(/(.*?)\.(.*)/))&&(g.file=f[0],g.filename=f[1],g.fileext=f[2]),(f=e.match(/(.*)\:([0-9]+)$/))&&(g.port=f[2],e=f[1]),(f=e.match(/(.*?)@(.*)/))&&(g.auth=f[1],e=f[2]),g.auth&&(f=g.auth.match(/(.*)\:(.*)/),g.user=f?f[1]:g.auth,g.pass=f?f[2]:void 0),g.hostname=e.toLowerCase(),"."===b.charAt(0))return c(b,g.hostname);a()&&(f=g.hostname.match(a()),f&&(g.tld=f[3],g.domain=f[2]?f[2]+"."+f[3]:void 0,g.sub=f[1]||void 0)),g.port=g.port||("https"===g.protocol?"443":"80"),g.protocol=g.protocol||("443"===g.port?"https":"http")}return b in g?g[b]:"[]"===b?g:void 0}}(),"undefined"!=typeof jQuery&&jQuery.extend({url:function(a,b){return window.url(a,b)}}); \ No newline at end of file