A platform for community discussion. Free, open, simple.
FEATURE: Onebox and Download for WEBP and AVIF (#23235)
Rafael dos Santos Silvad10e9a6c1d01
diff --git a/lib/onebox/engine/image_onebox.rb b/lib/onebox/engine/image_onebox.rbindex 2b6e08ac923..28d446ca5ff 100644--- a/lib/onebox/engine/image_onebox.rb+++ b/lib/onebox/engine/image_onebox.rb@@ -5,8 +5,8 @@ module Oneboxclass ImageOneboxinclude Engine- matches_content_type(%r{^image/(png|jpg|jpeg|gif|bmp|tif|tiff)$})- matches_regexp(%r{^(https?:)?//.+\.(png|jpg|jpeg|gif|bmp|tif|tiff)(\?.*)?$}i)+ matches_content_type(%r{^image/(png|jpg|jpeg|gif|bmp|tif|tiff|webp|avif)$})+ matches_regexp(%r{^(https?:)?//.+\.(png|jpg|jpeg|gif|bmp|tif|tiff|webp|avif)(\?.*)?$}i)def always_https?AllowlistedGenericOnebox.host_matches(uri, AllowlistedGenericOnebox.https_hosts)diff --git a/spec/lib/onebox/engine/image_onebox_spec.rb b/spec/lib/onebox/engine/image_onebox_spec.rbindex b3889bd528f..0b77ca280e0 100644--- a/spec/lib/onebox/engine/image_onebox_spec.rb+++ b/spec/lib/onebox/engine/image_onebox_spec.rb@@ -39,6 +39,18 @@ RSpec.describe Onebox::Engine::ImageOnebox do).to match(/<img/)end+ it "supports webp" do+ expect(Onebox.preview("https://www.gstatic.com/webp/gallery/1.sm.webp").to_s).to match(/<img/)+ end++ it "supports avif" do+ expect(+ Onebox.preview(+ "https://raw.githubusercontent.com/AOMediaCodec/av1-avif/master/testFiles/Xiph/abandoned_filmgrain.avif",+ ).to_s,+ ).to match(/<img/)+ end+it "supports image URLs with query parameters" doexpect(Onebox.preview(