diff --git a/lib/user_agent/browsers/base.rb b/lib/user_agent/browsers/base.rb index eda5a11..86e5e9d 100644 --- a/lib/user_agent/browsers/base.rb +++ b/lib/user_agent/browsers/base.rb @@ -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 diff --git a/spec/browsers/chrome_lighthouse_user_agent_spec.rb b/spec/browsers/chrome_lighthouse_user_agent_spec.rb new file mode 100644 index 0000000..5f54d4a --- /dev/null +++ b/spec/browsers/chrome_lighthouse_user_agent_spec.rb @@ -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