3 lines
104 KiB
JavaScript
3 lines
104 KiB
JavaScript
|
!function(a,o){"object"==typeof exports&&"undefined"!=typeof module?o(exports):"function"==typeof define&&define.amd?define(["exports"],o):o((a="undefined"!=typeof globalThis?globalThis:a||self).tldts={})}(this,(function(a){"use strict";function o(a,o){let e=0,i=a.length,s=!1;if(!o){if(a.startsWith("data:"))return null;for(;e<a.length&&a.charCodeAt(e)<=32;)e+=1;for(;i>e+1&&a.charCodeAt(i-1)<=32;)i-=1;if(47===a.charCodeAt(e)&&47===a.charCodeAt(e+1))e+=2;else{const o=a.indexOf(":/",e);if(-1!==o){const i=o-e,s=a.charCodeAt(e),n=a.charCodeAt(e+1),t=a.charCodeAt(e+2),r=a.charCodeAt(e+3),l=a.charCodeAt(e+4);if(5===i&&104===s&&116===n&&116===t&&112===r&&115===l);else if(4===i&&104===s&&116===n&&116===t&&112===r);else if(3===i&&119===s&&115===n&&115===t);else if(2===i&&119===s&&115===n);else for(let i=e;i<o;i+=1){const o=32|a.charCodeAt(i);if(!(o>=97&&o<=122||o>=48&&o<=57||46===o||45===o||43===o))return null}for(e=o+2;47===a.charCodeAt(e);)e+=1}}let o=-1,n=-1,t=-1;for(let r=e;r<i;r+=1){const e=a.charCodeAt(r);if(35===e||47===e||63===e){i=r;break}64===e?o=r:93===e?n=r:58===e?t=r:e>=65&&e<=90&&(s=!0)}if(-1!==o&&o>e&&o<i&&(e=o+1),91===a.charCodeAt(e))return-1!==n?a.slice(e+1,n).toLowerCase():null;-1!==t&&t>e&&t<i&&(i=t)}for(;i>e+1&&46===a.charCodeAt(i-1);)i-=1;const n=0!==e||i!==a.length?a.slice(e,i):a;return s?n.toLowerCase():n}function e(a){return a>=97&&a<=122||a>=48&&a<=57||a>127}function i(a){if(a.length>255)return!1;if(0===a.length)return!1;if(!e(a.charCodeAt(0))&&46!==a.charCodeAt(0)&&95!==a.charCodeAt(0))return!1;let o=-1,i=-1;const s=a.length;for(let n=0;n<s;n+=1){const s=a.charCodeAt(n);if(46===s){if(n-o>64||46===i||45===i||95===i)return!1;o=n}else if(!e(s)&&45!==s&&95!==s)return!1;i=s}return s-o-1<=63&&45!==i}const s=function({allowIcannDomains:a=!0,allowPrivateDomains:o=!1,detectIp:e=!0,extractHostname:i=!0,mixedInputs:s=!0,validHosts:n=null,validateHostname:t=!0}){return{allowIcannDomains:a,allowPrivateDomains:o,detectIp:e,extractHostname:i,mixedInputs:s,validHosts:n,validateHostname:t}}({});function n(a,e,n,t,r){const l=function(a){return void 0===a?s:function({allowIcannDomains:a=!0,allowPrivateDomains:o=!1,detectIp:e=!0,extractHostname:i=!0,mixedInputs:s=!0,validHosts:n=null,validateHostname:t=!0}){return{allowIcannDomains:a,allowPrivateDomains:o,detectIp:e,extractHostname:i,mixedInputs:s,validHosts:n,validateHostname:t}}(a)}(t);return"string"!=typeof a?r:(l.extractHostname?l.mixedInputs?r.hostname=o(a,i(a)):r.hostname=o(a,!1):r.hostname=a,0===e||null===r.hostname||l.detectIp&&(r.isIp=function(a){if(a.length<3)return!1;let o=a.startsWith("[")?1:0,e=a.length;if("]"===a[e-1]&&(e-=1),e-o>39)return!1;let i=!1;for(;o<e;o+=1){const e=a.charCodeAt(o);if(58===e)i=!0;else if(!(e>=48&&e<=57||e>=97&&e<=102||e>=65&&e<=90))return!1}return i}(u=r.hostname)||function(a){if(a.length<7)return!1;if(a.length>15)return!1;let o=0;for(let e=0;e<a.length;e+=1){const i=a.charCodeAt(e);if(46===i)o+=1;else if(i<48||i>57)return!1}return 3===o&&46!==a.charCodeAt(0)&&46!==a.charCodeAt(a.length-1)}(u),r.isIp)?r:l.validateHostname&&l.extractHostname&&!i(r.hostname)?(r.hostname=null,r):(n(r.hostname,l,r),2===e||null===r.publicSuffix?r:(r.domain=function(a,o,e){if(null!==e.validHosts){const a=e.validHosts;for(const e of a)if(function(a,o){return!!a.endsWith(o)&&(a.length===o.length||"."===a[a.length-o.length-1])}(o,e))return e}let i=0;if(o.startsWith("."))for(;i<o.length&&"."===o[i];)i+=1;return a.length===o.length-i?null:function(a,o){const e=a.length-o.length-2,i=a.lastIndexOf(".",e);return-1===i?a:a.slice(i+1)}(o,a)}(r.publicSuffix,r.hostname,l),3===e||null===r.domain?r:(r.subdomain=function(a,o){return o.length===a.length?"":a.slice(0,-o.length-1)}(r.hostname,r.domain),4===e||(r.domainWithoutSuffix=(m=r.domain,c=r.publicSuffix,m.slice(0,-c.length-1))),r))));var u,m,c}const t=function(){const a=[1,{}],o=[0,{city:a}];return[0,{ck:[0,{www:a}],jp:[0,{kawasaki:o,kitakyushu:o,kobe:o,nagoya:o,sapporo:o,sendai:o,yokohama:o}]}]}(),r=function(){const a=[1,{}],o=[2,{}],e=[1,{gov:a,com:a,org:a,net:a,edu:a}],i=[0,{"*":o}],s=[2,{preview:o}],n=[0,{relay:o}],
|
||
|
//# sourceMappingURL=index.umd.min.js.map
|