From 6ea641cc8648b025ed5f30b090c2abd4d1a5249f Mon Sep 17 00:00:00 2001 From: r0hanSH Date: Tue, 15 Feb 2022 04:08:32 +0530 Subject: [PATCH] fix(parse): case insensitive scheme - #412 --- src/URI.js | 2 +- src/URI.min.js | 2 +- test/urls.js | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+), 2 deletions(-) diff --git a/src/URI.js b/src/URI.js index 6505698..b6cdaf9 100644 --- a/src/URI.js +++ b/src/URI.js @@ -513,7 +513,7 @@ } // slashes and backslashes have lost all meaning for the web protocols (https, http, wss, ws) - string = string.replace(/^(https?|ftp|wss?)?:[/\\]*/, '$1://'); + string = string.replace(/^(https?|ftp|wss?)?:[/\\]*/i, '$1://'); // extract protocol if (string.substring(0, 2) === '//') { diff --git a/src/URI.min.js b/src/URI.min.js index 4a63660..e1ae1c4 100644 --- a/src/URI.min.js +++ b/src/URI.min.js @@ -35,7 +35,7 @@ function(){d.encode=escape;d.decode=unescape};d.unicode=function(){d.encode=F;d. "%21":"!","%24":"$","%26":"&","%27":"'","%28":"(","%29":")","%2A":"*","%2B":"+","%2C":",","%3B":";","%3D":"="}}},urnpath:{encode:{expression:/%(21|24|27|28|29|2A|2B|2C|3B|3D|40)/ig,map:{"%21":"!","%24":"$","%27":"'","%28":"(","%29":")","%2A":"*","%2B":"+","%2C":",","%3B":";","%3D":"=","%40":"@"}},decode:{expression:/[\/\?#:]/g,map:{"/":"%2F","?":"%3F","#":"%23",":":"%3A"}}}};d.encodeQuery=function(a,b){var c=d.encode(a+"");void 0===b&&(b=d.escapeQuerySpace);return b?c.replace(/%20/g,"+"):c};d.decodeQuery= function(a,b){a+="";void 0===b&&(b=d.escapeQuerySpace);try{return d.decode(b?a.replace(/\+/g,"%20"):a)}catch(c){return a}};var G={encode:"encode",decode:"decode"},l,t=function(a,b){return function(c){try{return d[b](c+"").replace(d.characters[a][b].expression,function(e){return d.characters[a][b].map[e]})}catch(e){return c}}};for(l in G)d[l+"PathSegment"]=t("pathname",G[l]),d[l+"UrnPathSegment"]=t("urnpath",G[l]);G=function(a,b,c){return function(e){var f=c?function(I){return d[b](d[c](I))}:d[b]; e=(e+"").split(a);for(var n=0,z=e.length;n