lib/search-bot-detector.rb
def hostname_matches?(hostname_suffixes)
    # N.B.: The ordering here is important:
    #
    # 1.  Get the _unverified_ hostname.
    # 2.  Check if it matches.
    # 3.  Verify the hostname against the IP.
    #
    # This is important to avoid a potentially long call to `Resolv::getaddresses` with an attacker-controlled hostname.

    hostname = unverified_hostname or return false
    hostname_suffixes.any? { |hostname_suffix| hostname.end_with?(hostname_suffix) } or return false

    hostname == verified_hostname
  end
# Check if the resolved and verified `hostname` matches any of the provided suffixes.
#
# @param [Array<String>]
#
# @return [Boolean]
Check if the resolved and verified `hostname` matches any of the provided suffixes.
Check if the resolved and verified ` hostname ` matches any of the provided suffixes .
def hostname_matches?(hostname_suffixes)
     1.  Get the _unverified_ hostname.
     2.  Check if it matches.
     3.  Verify the hostname against the IP.
     This is important to avoid a potentially long call to `Resolv::getaddresses` with an attacker-controlled hostname.
    hostname = unverified_hostname or return false
    hostname_suffixes.any? { |hostname_suffix| hostname.end_with?(hostname_suffix) } or return false
    hostname == verified_hostname
  end
def hostname_matches? ( hostname_suffixes ) hostname = unverified_hostname or return false hostname_suffixes . any? { | hostname_suffix | hostname . end_with? ( hostname_suffix ) } or return false hostname == verified_hostname end
Check if the resolved and verified `hostname` matches any of the provided suffixes.
Check if the resolved and verified ` hostname ` matches any of the provided suffixes .
# N.B.: The ordering here is important: # # 1.  Get the _unverified_ hostname. # 2.  Check if it matches. # 3.  Verify the hostname against the IP. # # This is important to avoid a potentially long call to `Resolv::getaddresses` with an attacker-controlled hostname.
None
Boolean
hostname_suffixes
None