Sha256: f375ecdfbd34b503a99c60c04ff6176314bc8ac4311c880e2fa2b2c9c44ff8bb

Contents?: true

Size: 613 Bytes

Versions: 5

Compression:

Stored size: 613 Bytes

Contents

require 'despamilator/filter'
require 'domainatrix'

module DespamilatorFilter

  class VeryLongDomainName < Despamilator::Filter

    def name
      'Very Long Domain Name'
    end

    def description
      'Detects unusually long domain names.'
    end

    def parse subject
      subject.text.scan(URI.regexp).each do |url_parts|
        url_parts.compact!
        next if !url_parts[1] or url_parts[1] !~ /(\w|-){5,}\.\w{2,5}/
        url = Domainatrix.parse('http://' + url_parts[1])
        subject.register_match!({:score => 0.4, :filter => self}) if url.domain.length > 20
      end
    end

  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
despamilator-2.1.4 lib/despamilator/filter/very_long_domain_name.rb
despamilator-2.1.3 lib/despamilator/filter/very_long_domain_name.rb
despamilator-2.1.2 lib/despamilator/filter/very_long_domain_name.rb
despamilator-2.1.1 lib/despamilator/filter/very_long_domain_name.rb
despamilator-2.1 lib/despamilator/filter/very_long_domain_name.rb