Sha256: 41f4c3a3d6737e9635847f4b55d2524f727a4fc04fa65a1505f0df69018e6e31
Contents?: true
Size: 912 Bytes
Versions: 43
Compression:
Stored size: 912 Bytes
Contents
module PublicSuffix # Monkey Patch to include the match logic class Domain # For Sanity def ==(other) name == other.name end # @return [ Boolean ] # def match(pattern) pattern = PublicSuffix.parse(pattern) unless pattern.is_a?(PublicSuffix::Domain) return name == pattern.name unless pattern.trd return false unless tld == pattern.tld && sld == pattern.sld matching_pattern?(pattern) end protected # @rturn [ Boolean ] def matching_pattern?(pattern) pattern_trds = pattern.trd.split('.') domain_trds = trd.split('.') case pattern_trds.first when '*' pattern_trds[1..-1] == domain_trds[1..-1] when '**' pa = pattern_trds[1..-1] pa_size = pa.size domain_trds[domain_trds.size - pa_size, pa_size] == pa else name == pattern.name end end end end
Version data entries
43 entries across 43 versions & 1 rubygems