From aed97c7babc1ff9b549d86a9eff618dababb678d Mon Sep 17 00:00:00 2001 From: jbrw Date: Wed, 10 Mar 2021 14:42:17 -0500 Subject: [PATCH] FIX: Add amazon sites to force_get_hosts (#12341) It has been observed that doing a HEAD against an Amazon store URL may result in a 405 error being returned. Skipping the HEAD request may result in an improved oneboxing experience when requesting these URLs. --- lib/oneboxer.rb | 7 ++++++- spec/components/oneboxer_spec.rb | 6 ++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/oneboxer.rb b/lib/oneboxer.rb index 19580fc4b41..79f5070374f 100644 --- a/lib/oneboxer.rb +++ b/lib/oneboxer.rb @@ -27,7 +27,12 @@ module Oneboxer end def self.force_get_hosts - @force_get_hosts ||= ['http://us.battle.net', 'https://news.yahoo.com/'] + @force_get_hosts ||= begin + hosts = ['http://us.battle.net', 'https://news.yahoo.com'] + amazon_suffixes = %w(com com.br ca cn fr de in it co.jp com.mx nl pl sa sg es se com.tr ae co.uk) + + hosts + amazon_suffixes.collect { |suffix| "https://www.amazon.#{suffix}" } + end end def self.force_custom_user_agent_hosts diff --git a/spec/components/oneboxer_spec.rb b/spec/components/oneboxer_spec.rb index c260a0ae261..5d6681422b7 100644 --- a/spec/components/oneboxer_spec.rb +++ b/spec/components/oneboxer_spec.rb @@ -329,4 +329,10 @@ describe Oneboxer do end end + describe '#force_get_hosts' do + it "includes Amazon sites" do + expect(Oneboxer.force_get_hosts).to include('https://www.amazon.ca') + end + end + end