Skip to content

Commit

Permalink
Handle a rare case that HTTP_USER_AGENT is nil.
Browse files Browse the repository at this point in the history
  • Loading branch information
genki committed Jan 22, 2012
1 parent 39dd505 commit 411081b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion lib/rack-turing-test.rb
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion 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.