mirror of
https://github.com/discourse/discourse.git
synced 2025-05-31 00:27:58 +08:00
FEATURE: Onebox can match engines based on the content_type (#13876)
* FEATURE: Onebox can match engines based on the content_type `FinalDestination` now returns the `content_type` of a resolved URL. `Oneboxer` passes this value to `Onebox` itself. Onebox engines can now specify a `matches_content_type` regex of content_types that the engine can handle, regardless of the URL. `ImageOnebox` will match URLs with a content type of `image/png`, `jpg`, `gif`, `bmp`, `tif`, etc. This will allow images that exist at a URL without a file type extension to be correctly rendered, assuming a valid `content_type` is returned.
This commit is contained in:
@ -59,9 +59,16 @@ describe Onebox::Preview do
|
||||
end
|
||||
|
||||
describe "#engine" do
|
||||
let(:preview_image_url) { "http://www.example.com/image/without/file_extension" }
|
||||
let(:preview_image) { described_class.new(preview_image_url, content_type: 'image/png') }
|
||||
|
||||
it "returns an engine" do
|
||||
expect(preview.send(:engine)).to be_an(Onebox::Engine)
|
||||
end
|
||||
|
||||
it "can match based on content_type" do
|
||||
expect(preview_image.send(:engine)).to be_an(Onebox::Engine::ImageOnebox)
|
||||
end
|
||||
end
|
||||
|
||||
describe "xss" do
|
||||
|
Reference in New Issue
Block a user