Skip to content

Commit

Permalink
Merge pull request #67 from ankurp/fix/chrome-lighthouse
Browse files Browse the repository at this point in the history
Adding fix for Chrome Lighthouse not being detected as a bot
  • Loading branch information
gshutler authored Dec 4, 2024
2 parents 3ed4d04 + 22d2271 commit d61055e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/user_agent/browsers/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ def bot?
# list will be rejected.
elsif detect_comment_match(/bot/i)
true
# Google PageSpeed Insights adds "Chrome-Lighthouse" to the user agent
# https://stackoverflow.com/questions/16403295/what-is-the-name-of-the-google-pagespeed-user-agent
elsif detect_product("Chrome-Lighthouse")
true
elsif product = application.product
product.include?('bot')
else
Expand Down
9 changes: 9 additions & 0 deletions spec/browsers/chrome_lighthouse_user_agent_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
require 'user_agent'

describe "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4590.2 Safari/537.36 Chrome-Lighthouse" do
before do
@useragent = UserAgent.parse("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4590.2 Safari/537.36 Chrome-Lighthouse")
end

it { expect(@useragent).to be_bot }
end

0 comments on commit d61055e

Please sign in to comment.