Commit 0634b222 authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Merge branch '340666-WebP-images-dont-embed-in-markdown' into 'master'

Allow relative WebP image embed in markdown

See merge request gitlab-org/gitlab!73426
parents 3c8e582e 9d9618fc
...@@ -47,7 +47,7 @@ module Gitlab ...@@ -47,7 +47,7 @@ module Gitlab
end end
def image? def image?
['.png', '.jpg', '.jpeg', '.gif', '.svg'].include?(extname.downcase) ['.png', '.jpg', '.jpeg', '.gif', '.svg', '.webp'].include?(extname.downcase)
end end
# Internal: Lookup mime type for extension. # Internal: Lookup mime type for extension.
......
...@@ -7,6 +7,7 @@ RSpec.describe Gitlab::BlobHelper do ...@@ -7,6 +7,7 @@ RSpec.describe Gitlab::BlobHelper do
let(:project) { create(:project) } let(:project) { create(:project) }
let(:blob) { fake_blob(path: 'file.txt') } let(:blob) { fake_blob(path: 'file.txt') }
let(:webp_blob) { fake_blob(path: 'file.webp') }
let(:large_blob) { fake_blob(path: 'test.pdf', size: 2.megabytes, binary: true) } let(:large_blob) { fake_blob(path: 'test.pdf', size: 2.megabytes, binary: true) }
describe '#extname' do describe '#extname' do
...@@ -62,8 +63,15 @@ RSpec.describe Gitlab::BlobHelper do ...@@ -62,8 +63,15 @@ RSpec.describe Gitlab::BlobHelper do
end end
describe '#image?' do describe '#image?' do
it 'returns false' do context 'with a .txt file' do
expect(blob.image?).to be_falsey it 'returns false' do
expect(blob.image?).to be_falsey
end
end
context 'with a .webp file' do
it 'returns true' do
expect(webp_blob.image?).to be_truthy
end
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment