FIX: An unresolved blank uri should attempt an alternate Oneboxing strategy, if available (#13070)

This commit is contained in:
jbrw 2021-05-14 15:23:20 -04:00 committed by GitHub
parent 8801a27cc6
commit a24b6daa87
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 6 deletions

View File

@ -427,12 +427,10 @@ module Oneboxer
args = { link: url } args = { link: url }
if fd.status == :invalid_address if fd.status == :invalid_address
args[:error_message] = I18n.t("errors.onebox.invalid_address", hostname: fd.hostname) args[:error_message] = I18n.t("errors.onebox.invalid_address", hostname: fd.hostname)
elsif fd.status_code elsif (fd.status_code || uri.nil?) && available_strategies.present?
# Try a different oneboxing strategy, if we have any options left: # Try a different oneboxing strategy, if we have any options left:
if available_strategies.present? return external_onebox(url, available_strategies)
return external_onebox(url, available_strategies) elsif fd.status_code
end
args[:error_message] = I18n.t("errors.onebox.error_response", status_code: fd.status_code) args[:error_message] = I18n.t("errors.onebox.error_response", status_code: fd.status_code)
end end

View File

@ -391,7 +391,7 @@ describe Oneboxer do
Oneboxer.clear_preferred_strategy!(hostname) Oneboxer.clear_preferred_strategy!(hostname)
end end
it "uses mutiple strategies" do it "uses multiple strategies" do
default_ordered = Oneboxer.strategies.keys default_ordered = Oneboxer.strategies.keys
custom_ordered = Oneboxer.ordered_strategies(hostname) custom_ordered = Oneboxer.ordered_strategies(hostname)
expect(custom_ordered).to eq(default_ordered) expect(custom_ordered).to eq(default_ordered)