2018-06-30 17:01:23 -06:00
|
|
|
var tld = {
|
|
|
|
normalize(d) { return d; },
|
|
|
|
|
|
|
|
isIp(d) { return this._ipRx.test(d); },
|
|
|
|
|
|
|
|
getDomain(domain) {
|
|
|
|
if (domain === "localhost" || this.isIp(domain)) return domain;
|
|
|
|
|
|
|
|
domain = this.normalize(domain);
|
|
|
|
var pos = domain.search(this._tldEx);
|
|
|
|
if(pos === -1 ) {
|
|
|
|
pos = domain.search(this._tldRx);
|
|
|
|
if (pos === -1) {
|
|
|
|
// TLD not in the public suffix list, fall back to the "one-dot rule"
|
|
|
|
pos = domain.lastIndexOf(".");
|
|
|
|
if (pos === -1) {
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pos = domain.lastIndexOf(".", pos - 1) + 1;
|
|
|
|
} else if(domain[pos] == ".") {
|
|
|
|
++pos;
|
|
|
|
}
|
|
|
|
return pos <= 0 ? domain : domain.substring(pos);
|
|
|
|
},
|
|
|
|
|
|
|
|
getPublicSuffix(domain) {
|
|
|
|
if (this.isIp(domain)) return "";
|
|
|
|
|
|
|
|
domain = this.normalize(domain);
|
|
|
|
var pos = domain.search(this._tldEx);
|
|
|
|
if(pos < 0) {
|
|
|
|
pos = domain.search(this._tldRx);
|
|
|
|
if(pos >= 0 && domain[pos] == ".") pos++;
|
|
|
|
} else {
|
|
|
|
pos = domain.indexOf(".", pos + 1) + 1;
|
|
|
|
}
|
|
|
|
return pos < 0 ? "" : domain.substring(pos);
|
|
|
|
},
|
|
|
|
|
|
|
|
_ipRx: /^(?:0\.|[1-9]\d{0,2}\.){3}(?:0|[1-9]\d{0,2})$|:.*:/i,
|
|
|
|
|
2018-07-26 03:45:55 -06:00
|
|
|
_tldRx: /(?:\.|^)(?:s(?:h(?:i(?:(?:m(?:o(?:(?:go\.fukushim|fusa\.chib|ji\.okinaw|ichi\.nar)a|k(?:awa\.hokkaido|itayama\.nara)|n(?:oseki\.yamaguchi|ita\.gunma)|tsu(?:ke\.tochig|ma\.ibarak)i|da(?:te\.ibaraki|\.shizuoka)|suwa\.nagano)|a(?:m(?:aki\.hokkaido|oto\.osaka)|(?:(?:ne\.shima)?n|\.mi)e|bara\.nagasaki|da\.shizuoka)|izu\.(?:hokkaido|shizuoka))|n(?:(?:a(?:nomachi\.nagan|gawa\.toky)|onsen\.hyog)o|g(?:u\.(?:(?:wakayam|fukuok)a|hyogo)|o\.aomori)|j(?:o\.(?:yamagat|okayam|nar)a|uku\.tokyo)|to(?:ku\.hokkaido|mi\.miyazaki|\.gunma)|(?:yoshitomi\.fukuok|ichi\.hiroshim)a|shi(?:notsu\.hokkaido|ro\.aichi)|kamigoto\.nagasaki)|r(?:a(?:k(?:awa\.(?:fukushima|gifu)|o\.chiba)|(?:hama\.wakayam|taka\.yamagat)a|o(?:i\.hokkaido|ka\.saitama)|nuka\.hokkaido)|o(?:i(?:shi\.(?:miyagi|saga)|\.chiba)|sato\.ibaraki)|iuchi\.hokkaido)|b(?:u(?:kawa\.gunma|ya\.tokyo)|ata\.(?:niigata|miyagi)|e(?:cha|tsu)\.hokkaido)|(?:chi(?:kashuku\.miyag|nohe\.aomor)|iba\.miyazak|tara\.aich)i|o(?:(?:gama\.miya|ya\.tochi)gi|jiri\.nagano)|s(?:(?:hikui\.tokushim|ui\.chib)a|o\.hyogo)|zu(?:(?:oka\.shizu)?oka|kuishi\.iwate)|(?:jonawate\.osak|g)a|wa\.iwate)\.jp|k(?:(?:a(?:(?:ma\.miyag|tsu\.aich)i|(?:be|oi)\.hokkaido|\.ishikawa)|okuchuo\.ehime|i\.saitama)\.jp|sha)|ftedit\.io|a)|o(?:(?:(?:bara\.hiroshi|o\.okaya)m|nai\.(?:yamagat|fukuok))a\.jp|w(?:a\.(?:(?:fukushi|gun)ma|yamanashi)\.jp|\.aero|time)?|p(?:\.(?:h[tu]|pl|ro)|ping)?|uji|es)|a(?:(?:r(?:i\.hokkaido\.j)?|kotan\.hokkaido\.j)p|cknet\.nu|ngrila|w)|e(?:ll(?:\.museum)?|rbrooke\.museum)|unan\.yamaguchi\.jp|riram|\.cn)?|a(?:n(?:d(?:(?:(?:e(?:\.(?:m[oø]re-og-romsdal|vestfold)|fjord)|nes(?:sj[oø]en)?|[oø]y)\.n|cats\.i)o|vik(?:coromant)?|a\.hyogo\.jp|iego\.museum)|(?:(?:agochi\.tokushim|jo\.niigat|uki\.kagaw|go\.nar)a|n(?:ohe\.aomori|an\.hyogo))\.jp|t(?:a(?:(?:barbara|cruz|fe)\.museum|maria\.br)|oandre\.br)|o(?:\.tochigi\.jp|k\.pl|fi)|francisco\.museum)|k(?:(?:a(?:i(?:\.(?:(?:ibarak|fuku)i|osaka)|minato\.tottori)|(?:(?:\.hiroshi|do\.saita)m|ta\.yamagat)a|e\.(?:nagano|chiba)|hogi\.gifu|ki\.nagano|wa\.kochi)|egawa\.yamagata|yo\.kyoto)\.jp|u(?:ra(?:(?:\.(?:tochigi|chiba)|gawa\.ibaraki|i\.nara)\.jp)?|(?:ho)?\.nagano\.jp))|(?:(?:ga(?:(?:mihara\.kanagaw|e\.yamagat)a|(?:\.saga)?)|y(?:ama\.(?:saitam|osak)a|o\.hyogo)|do\.niigata|bae\.fukui)\.j)?p|i(?:(?:t(?:(?:ama\.sait)?ama|o\.miyazaki)|k(?:ai\.nagasaki|i\.oita)|gawa\.fukuoka|jo\.ehime)\.jp|ntlouis\.museum)|l(?:(?:(?:a(?:ngen|t)|tdal)\.n|ud\.b)o|vador(?:dali\.museum|\.br)|e(?:m\.museum|rno\.it)?|zburg\.museum|on)|s(?:(?:a(?:guri\.fukuoka|yama\.hyogo)|ebo\.nagasaki)\.jp|katchewan\.museum|sari\.it)?|m(?:(?:egawa\.fukushim|ukawa\.kanagaw)a\.jp|s(?:club|ung)|nanger\.no|pa\.br)|r(?:(?:ufutsu|oma)\.hokkaido\.jp|(?:d(?:egn|ini)a)?\.it|psborg\.no|l)|t(?:(?:(?:osho\.okay|te\.sait)a|sumasendai\.kagoshi)ma\.jp|x\.museum)|v(?:e(?:s-the-whales\.com)?|annahga\.museum|ona\.it)|\.(?:gov\.(?:au|pl)|(?:edu\.)?au|c(?:om|r)|it)|o(?:(?:bernardo|gonca)\.br|tome\.st)|-east-1\.elasticbeanstalk\.com|(?:u(?:herad|da)\.n|x)o|fe(?:ty(?:\.aero)?)?|arland)?|e(?:[sw]|r(?:v(?:e(?:(?:(?:(?:counterstri|qua)k|exchang)e|h(?:alflife|umour|ttp)|p(?:ics|2p)|sarcasm|irc)\.com|b(?:bs\.(?:com|net|org)|eer\.com|log\.net)|m(?:inecraft\.net|p3\.com)|ftp\.(?:com|net|org)|game\.(?:com|org))|ice(?:s(?:\.aero)?|\.gov\.uk))|a(?:nishi)?\.hiroshima\.jp)|(?:i(?:rou?\.niigata|hi\.nagasaki|ka\.kyoto|yo\.ehime)|ki(?:(?:gahara)?\.gifu|kawa\.niigata)|m(?:boku\.akita|ine\.miyagi))\.jp|l(?:ls(?:-(?:for-(?:less|u)\.com|it\.net)|yourhome\.org)|fip\.(?:info|biz|com|net|org)|(?:j(?:ord|e)|bu)?\.no|ect)|t(?:(?:o(?:uchi\.okayama|\.aichi)|agaya\.tokyo)\.jp|t(?:le(?:ment|rs)\.museum|su\.osaka\.jp))|c(?:ur(?:ity(?:tactics\.com)?|e)|\.ps)|\.(?:(?:gov|leg)\.br|eu\.org|net)|a(?:port\.museum|rch|t)|n(?:nan\.osaka\.jp|er)|v(?:astopol\.ua|en)|x(?:\.(?:hu|pl)|y)?|bastopol\.ua|jny\.pl|oul\.kr|ek)?|3(?:-(?:website(?:-(?:ap-(?:southeast-[12]|northeast-1)|us-(?:west-[12]|east-1)|(?:eu-we|sa-ea)st-1)|\.(?:ap-(?:northeast-2|south-1)|eu-(?:central-1|west-[23])|ca-central-1|us-east-2))|(?:(?:fips-us-gov-we|sa-ea)st|ca-central)-1|ap-(?:south(?:east-[12]|-1)|northea
|
2018-06-30 17:01:23 -06:00
|
|
|
,
|
|
|
|
_tldEx: /(?:\.|^)(?:city\.(?:k(?:itakyushu|awasaki|obe)|(?:yokoham|nagoy)a|s(?:apporo|endai))\.jp|www\.ck)$/
|
|
|
|
}
|