lib/banhammer.rb
####
# Returns the total number of URLs found, returns 0 if no urls are found.
# 	:high sensitivity - matches sneaky patterns like www this-is-a-domain com
# 	default sensitivity - matches http(s) links, and typical www.this-is-a-domain.com type links
####
Returns the total number of URLs found, returns 0 if no urls are found.
Returns the total number of URLs found returns 0 if no urls are found .
def count_links(body)
      count = 0
      if @link_sensitivity_level == :high
        body.gsub(/(h\w+:\/\/[a-z\-0-9 ]+[a-z\-0-9\.]+)|(www[ ][a-z\-0-9]+[ ][a-z]+)/i) { |s| if s.length <= 63 && s.length >= 3 && s.start_with?("-", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9") == false then count += 1 end }
      else
        body.gsub(/h\w+:\/\/[a-z\-0-9]+\.[a-z\-0-9]+/i) { |s| if s.length <= 63 && s.length >= 3 then count += 1 end }
      end
      count
    end
def count_links ( body ) count = 0 if @link_sensitivity_level == :high body . gsub ( / (h \w +: \/ \/ [a-z \- 0-9 ]+[a-z \- 0-9 \. ]+)|(www[ ][a-z \- 0-9]+[ ][a-z]+) /i ) { | s | if s . length <= 63 && s . length >= 3 && s . start_with? ( "-" , "0" , "1" , "2" , "3" , "4" , "5" , "6" , "7" , "8" , "9" ) == false then count += 1 end } else body . gsub ( / h \w +: \/ \/ [a-z \- 0-9]+ \. [a-z \- 0-9]+ /i ) { | s | if s . length <= 63 && s . length >= 3 then count += 1 end } end count end
Returns the total number of URLs found, returns 0 if no urls are found.
Returns the total number of URLs found returns 0 if no urls are found .
body
<not_specific>