diff --git a/lib/user_agent/browsers/all.rb b/lib/user_agent/browsers/all.rb index 42b1bfd..276cfed 100644 --- a/lib/user_agent/browsers/all.rb +++ b/lib/user_agent/browsers/all.rb @@ -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 @@ -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 @@ -72,6 +72,11 @@ 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. @@ -79,7 +84,7 @@ def bot? # 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