Class: PublicSuffix::Domain
- Inherits:
-
Object
- Object
- PublicSuffix::Domain
- Defined in:
- lib/cms_scanner/public_suffix/domain.rb
Overview
Monkey Patch to include the match logic
Instance Method Summary collapse
-
#==(other) ⇒ Object
For Sanity.
-
#match(pattern) ⇒ Object
TODO: better code for this method rubocop:disable all.
Instance Method Details
#==(other) ⇒ Object
For Sanity
5 6 7 |
# File 'lib/cms_scanner/public_suffix/domain.rb', line 5 def ==(other) name == other.name end |
#match(pattern) ⇒ Object
TODO: better code for this method rubocop:disable all
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/cms_scanner/public_suffix/domain.rb', line 11 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 pattern_trds = pattern.trd.split('.') domain_trds = trd.split('.') case pattern_trds.first when '*' pattern_trds[1..pattern_trds.size] == domain_trds[1..domain_trds.size] when '**' pa = pattern_trds[1..pattern_trds.size] domain_trds[domain_trds.size - pa.size, pa.size] == pa else name == pattern.name end end |