Skip to content

Commit

Permalink
Ensure UA has application part
Browse files Browse the repository at this point in the history
  • Loading branch information
josh committed Oct 12, 2012
1 parent d3c4130 commit 4646008
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions lib/user_agent/browsers/all.rb
Expand Up @@ -29,11 +29,11 @@ def application
end

def browser
application.product
application && application.product
end

def version
application.version
application && application.version
end

def platform
Expand Down Expand Up @@ -63,7 +63,7 @@ def mobile?
true
elsif detect_product('Mobile')
true
elsif application.comment &&
elsif application && application.comment &&
application.comment.detect { |k, v| k =~ /^IEMobile/ }
true
else
Expand All @@ -72,14 +72,19 @@ def mobile?
end

def bot?
# If UA has no application type, its probably generated by a
# shitty bot.
if application.nil?
true

# Match common case when bots refer to themselves as bots in
# the application comment. There are no standards for how bots
# should call themselves so its not an exhaustive method.
#
# If you want to expand the scope, override the method and
# provide your own regexp. Any patches to future extend this
# list will be rejected.
if comment = application.comment
elsif comment = application.comment
comment.any? { |c| c =~ /bot/i }
else
false
Expand Down

0 comments on commit 4646008

Please sign in to comment.