GoScrobble/web/node_modules/native-url/dist/index.umd.js

3 lines
3.7 KiB
JavaScript
Raw Permalink Normal View History

2022-04-25 02:47:15 +00:00
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("querystring")):"function"==typeof define&&define.amd?define(["exports","querystring"],t):t(e.nativeUrl={},e.querystring)}(this,function(e,t){t=t&&t.hasOwnProperty("default")?t.default:t;var r=/https?|ftp|gopher|file/;function o(e){"string"==typeof e&&(e=f(e));var o=function(e,t,r){var o=e.auth,a=e.hostname,s=e.protocol||"",h=e.pathname||"",n=e.hash||"",c=e.query||"",p=!1;o=o?encodeURIComponent(o).replace(/%3A/i,":")+"@":"",e.host?p=o+e.host:a&&(p=o+(~a.indexOf(":")?"["+a+"]":a),e.port&&(p+=":"+e.port)),c&&"object"==typeof c&&(c=t.encode(c));var l=e.search||c&&"?"+c||"";return s&&":"!==s.substr(-1)&&(s+=":"),e.slashes||(!s||r.test(s))&&!1!==p?(p="//"+(p||""),h&&"/"!==h[0]&&(h="/"+h)):p||(p=""),n&&"#"!==n[0]&&(n="#"+n),l&&"?"!==l[0]&&(l="?"+l),{protocol:s,host:p,pathname:h=h.replace(/[?#]/g,encodeURIComponent),search:l=l.replace("#","%23"),hash:n}}(e,t,r);return""+o.protocol+o.host+o.pathname+o.search+o.hash}var a="http://",s="w.w",h=a+s,n=/^https?|ftp|gopher|file/,c=/^(.*?)([#?].*)/,p=/^([a-z0-9.+-]*:)(\/{0,3})(.*)/i,l=/^([a-z0-9.+-]*:)?\/\/\/*/i,i=/^([a-z0-9.+-]*:)(\/{0,2})\[(.*)\]$/i;function u(e){try{return decodeURI(e)}catch(t){return e}}function f(e,r,a){void 0===r&&(r=!1),void 0===a&&(a=!1);var f=(e=e.trim()).match(c);e=f?u(f[1]).replace(/\\/g,"/")+f[2]:u(e).replace(/\\/g,"/"),i.test(e)&&"/"!==e.slice(-1)&&(e+="/");var m=!/(^javascript)/.test(e)&&e.match(p),d=l.test(e),v="";m&&(n.test(m[1])||(v=m[1].toLowerCase(),e=""+m[2]+m[3]),m[2]||(d=!1,n.test(m[1])?(v=m[1],e=""+m[3]):e="//"+m[3]),3!==m[2].length&&1!==m[2].length||(v=m[1],e="/"+m[3]));var g,y=e.match(/(:[0-9]+)/),b="";y&&y[1]&&3===y[1].length&&(e=e.replace(b=y[1],b+"00"));var w={},U="",R="";try{g=new URL(e)}catch(t){U=t,v||a||!/^\/\//.test(e)||/^\/\/.+[@.]/.test(e)||(R="/",e=e.substr(1));try{g=new URL(e,h)}catch(e){return w.protocol=v,w.href=v,w}}w.slashes=d&&!R,w.host=g.host===s?"":g.host,w.hostname=g.hostname===s?"":g.hostname.replace(/(\[|\])/g,""),w.protocol=U?v||null:g.protocol,w.search=g.search.replace(/\\/g,"%5C"),w.hash=g.hash.replace(/\\/g,"%5C");var j=e.split("#");!w.search&&~j[0].indexOf("?")&&(w.search="?"),w.hash||""!==j[1]||(w.hash="#"),w.query=r?t.decode(g.search.substr(1)):w.search.substr(1),w.pathname=R+u(g.pathname).replace(/"/g,"%22"),"about:"===w.protocol&&"blank"===w.pathname&&(w.protocol="",w.pathname=""),U&&"/"!==e[0]&&(w.pathname=w.pathname.substr(1)),v&&!n.test(v)&&"/"!==e.slice(-1)&&"/"===w.pathname&&(w.pathname=""),w.path=w.pathname+w.search,w.auth=[g.username,g.password].map(decodeURIComponent).filter(Boolean).join(":"),w.port=g.port,b&&(w.host=w.host.replace(b+"00",b),w.port=w.port.slice(0,-2)),w.href=R?""+w.pathname+w.search+w.hash:o(w);var x=/^(file)/.test(w.href)?["host","hostname"]:[];return Object.keys(w).forEach(function(e){~x.indexOf(e)||(w[e]=w[e]||null)}),w}var m=/^([a-z0-9.+-]*:\/\/\/)([a-z0-9.+-]:\/*)?/i,d=/https?|ftp|gopher|file/;function v(e,t){var r="string"==typeof e?f(e):e;e="object"==typeof e?o(e):e;var s=f(t),n="";r.protocol&&!r.slashes&&(n=r.protocol,e=e.replace(r.protocol,""),n+="/"===t[0]||"/"===e[0]?"/":""),n&&s.protocol&&(n="",s.slashes||(n=s.protocol,t=t.replace(s.protocol,"")));var c=e.match(m);c&&!s.protocol&&(e=e.substr((n=c[1]+(c[2]||"")).length),/^\/\/[^\/]/.test(t)&&(n=n.slice(0,-1)));var p=new URL(e,h+"/"),l=new URL(t,p).toString().replace(h,""),i=s.protocol||r.protocol;return i+=r.slashes||s.slashes?"//":"",!n&&i?l=l.replace(a,i):n&&(l=l.replace(a,"")),d.test(l)||~t.indexOf(".")||"/"===e.slice(-1)||"/"===t.slice(-1)||"/"!==l.slice(-1)||(l=l.slice(0,-1)),n&&(l=n+("/"===l[0]?l.substr(1):l)),l}e.parse=f,e.format=o,e.resolve=v,e.resolveObject=function(e,t){return f(v(e,t))}});
//# sourceMappingURL=index.umd.js.map