lib/bad_browser/user_agent.rb
def match_safari
    unless match_with(:safari, /Version\/([\d\.[dp1]*]+) Safari/)
      if match = match_agent(/AppleWebKit\/(\d[\.\d]*)/)
        # find may return nil so this is a two step process
        result = @@safari_map.find { |v, pair| match.last >= pair.first && match.last <= pair.last }
        @version = BrowserVersion.new result.first.to_s if result
        @browser = :safari

      elsif @string.include?('Safari') || @string.include?('AppleWebKit')
        @browser = :safari

      end
    end
  end
# We need a special method just to handle Safari since it's user agent strings are not
# as easily parsed as other browsers. If everything fails, we will at least look for 'Safari'
# in the user-agent string to positively match the vendor.
We need a special method just to handle Safari since it's user agent strings are not
as easily parsed as other browsers. If everything fails, we will at least look for 'Safari'
in the user-agent string to positively match the vendor.
We need a special method just to handle Safari since it ' s user agent strings are not as easily parsed as other browsers . If everything fails we will at least look for ' Safari ' in the user - agent string to positively match the vendor .
def match_safari
    unless match_with(:safari, /Version\/([\d\.[dp1]*]+) Safari/)
      if match = match_agent(/AppleWebKit\/(\d[\.\d]*)/)
        result = @@safari_map.find { |v, pair| match.last >= pair.first && match.last <= pair.last }
        @version = BrowserVersion.new result.first.to_s if result
        @browser = :safari
      elsif @string.include?('Safari') || @string.include?('AppleWebKit')
        @browser = :safari
      end
    end
  end
def match_safari unless match_with ( :safari , / Version \/ ([ \d \. [dp1]*]+) Safari / ) if match = match_agent ( / AppleWebKit \/ ( \d [ \. \d ]*) / ) result = @@safari_map . find { | v , pair | match . last >= pair . first && match . last <= pair . last } @version = BrowserVersion . new result . first . to_s if result @browser = :safari elsif @string . include? ( 'Safari' ) || @string . include? ( 'AppleWebKit' ) @browser = :safari end end end
We need a special method just to handle Safari since it's user agent strings are not
as easily parsed as other browsers.
We need a special method just to handle Safari since it ' s user agent strings are not as easily parsed as other browsers .
# find may return nil so this is a two step process