Skip to content
Browse files

Handle a rare case that HTTP_USER_AGENT is nil.

  • Loading branch information...
1 parent 39dd505 commit 411081b551289f848f62bc1a52bda10039195ed5 @genki committed Jan 22, 2012
Showing with 5 additions and 2 deletions.
  1. +4 −1 lib/rack-turing-test.rb
  2. +1 −1 lib/rack-turing-test/version.rb
View
5 lib/rack-turing-test.rb
@@ -16,8 +16,11 @@ module TuringTest
/teoma/i,
]).freeze
+ # Returns true if the request came from bot.
+ # Sometimes, there's a case that the HTTP_USERAGENT is nil.
+ # It's very rare for ordinary browsers. So, simply we observe it as a bot.
def bot?
- !!user_agent.match(PATTERN)
+ user_agent.nil? || !!user_agent.match(PATTERN)
end
end
View
2 lib/rack-turing-test/version.rb
@@ -1,5 +1,5 @@
module Rack
module TuringTest
- VERSION = "0.1.1"
+ VERSION = "0.1.2"
end
end

0 comments on commit 411081b

Please sign in to comment.
Something went wrong with that request. Please try again.