DEV: Fix edge case for `InlineUploads`.

This commit is contained in:
Guo Xiang Tan 2019-06-14 13:47:44 +08:00
parent ecb2fd8222
commit 5d16d10a9e
2 changed files with 15 additions and 1 deletions

View File

@ -100,7 +100,7 @@ class InlineUploads
end end
end end
markdown.scan(/((\n|\s)+)#{regexp}/) do |match| markdown.scan(/(([\n\s\)\]\<])+)#{regexp}/) do |match|
if matched_uploads(match[2]).present? if matched_uploads(match[2]).present?
next if indexes.include?($~.offset(3)[0]) next if indexes.include?($~.offset(3)[0])

View File

@ -234,6 +234,20 @@ RSpec.describe InlineUploads do
MD MD
end end
it "should correct image URLs that follows an image md" do
md = <<~MD
![image|690x290](#{upload.short_url})#{Discourse.base_url}#{upload2.url}
<#{Discourse.base_url}#{upload2.url}>
MD
expect(InlineUploads.process(md)).to eq(<<~MD)
![image|690x290](#{upload.short_url})#{Discourse.base_url}#{upload2.short_path}
<#{Discourse.base_url}#{upload2.short_path}>
MD
end
it "should correct image URLs to the short version" do it "should correct image URLs to the short version" do
md = <<~MD md = <<~MD
![image|690x290](#{upload.short_url}) ![image|690x290](#{upload.short_url})