Public Suffix List/Formal Algorithmについて、ここに記述してください。 == Formal algorithm == Here is an algorithm for determining the Public Suffix of a domain. (Note: it may not be the most efficient algorithm.) The domain and all rules must be canonicalized in the normal way for hostnames - lower-case, Punycode (RFC 3492). === Definitions === * The Public Suffix List consists of a series of lines, separated by \n. * Each line is only read up to the first whitespace; entire lines can also be commented using //. * Each line which is not entirely whitespace or begins with a comment contains a rule. * A rule may begin with a "!" (exclamation mark). If it does, it is labelled as a "exception rule" and then treated as if the exclamation mark is not present. * A domain or rule can be split into a list of labels using the separator "." (dot). The separator is not part of any of the labels. * A domain is said to match a rule if, when the domain and rule are both split, and one compares the labels from the rule to the labels from the domain, beginning at the right hand end, one finds that for every pair either they are identical, or that the label from the rule is "*" (star). The domain may legitimately have labels remaining at the end of this matching process. ---- 右から左へマッチさせる。  ルールのラベルが尽きるまで(各ラベルが一致)、またはルールのラベルに*が現れるまで。 ドメインのラベルに対応させなかったものが残っていてもよい。 === Algorithm === Match domain against all rules and take note of the matching ones. * If no rules match, the prevailing rule is "*". * If more than one rule matches, the prevailing rule is the one which is an exception rule. * If there is no matching exception rule, the prevailing rule is the one with the most labels. * If the prevailing rule is a exception rule, modify it by removing the leftmost label. * The public suffix is the set of labels from the domain which directly match the labels of the prevailing rule (joined by dots). * The registered or registrable domain is the public suffix plus one additional label. ---- "exception rule"が優先する。  なければ、一番段数の多いものが優先する。 "exception rule"の場合、最左のラベルを除いて、適用する。