Permalink
Browse files

Added Chrome support

  • Loading branch information...
1 parent 5ff62dd commit 59e5dc9a241526caa59b0ffdcc38e6e1337002d9 @tj committed Aug 28, 2009
Showing with 6 additions and 3 deletions.
  1. +3 −3 lib/user-agent/agent.rb
  2. +3 −0 spec/agents_spec.rb
View
@@ -89,9 +89,9 @@ def self.engine_version_for_user_agent string
def self.version_for_user_agent string
case string
+ when /chrome/i ; $1 if string =~ /chrome\/([\d\w\.]+)/i
when /safari/i ; $1 if string =~ /version\/([\d\w\.]+)/i
- when /msie/i ; $1 if string =~ /msie\s*([\d\w\.]+)/i
- when /opera/i ; $1 if string =~ /opera[\/ ]([\d\w\.]+)/i
+ else $1 if string =~ /#{name_for_user_agent(string)}[\/ ]([\d\w\.]+)/i
end
end
@@ -100,9 +100,9 @@ def self.version_for_user_agent string
def self.engine_for_user_agent string
case string
- when /chrome/i ; :chrome
when /konqueror/i ; :konqueror
when /webkit/i ; :webkit
+ when /chrome/i ; :chrome
when /presto/i ; :presto
when /gecko/i ; :gecko
when /msie/i ; :msie
View
@@ -31,4 +31,7 @@ def test name, version, os, engine, engine_version, string
test :Opera, '9.64', :Linux, :presto, '2.1.1', 'Opera/9.64 (X11; Linux i686; U; Linux Mint; it) Presto/2.1.1'
test :Opera, '9.00', :Wii, :unknown, nil, 'Opera/9.00 (Nintindo Wii; U; ; 103858; Wii Shop Channel/1.0; en)'
+ test :Chrome, '4.0.202.2', :Linux, :webkit, '532.0', 'Mozilla/5.0 (X11; U; Linux i686 (x86_64); en-US) AppleWebKit/532.0 (KHTML, like Gecko) Chrome/4.0.202.2 Safari/532.0'
+ test :Chrome, '0.2.149.27', :'Windows 2003', :webkit, '525.13', 'Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US) AppleWebKit/525.13 (KHTML, like Gecko) Chrome/0.2.149.27 Safari/525.13'
+ test :Chrome, '0.2.149.30', :'Windows Vista', :webkit, '525.13', 'Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US) AppleWebKit/525.13 (KHTML, like Gecko) Chrome/0.2.149.30 Safari/525.13'
end

0 comments on commit 59e5dc9

Please sign in to comment.