FIX: BBcode edge case for `InlineUploads`.

This commit is contained in:
Guo Xiang Tan 2019-06-20 11:47:32 +08:00
parent f096c994de
commit 53efb7bd24
2 changed files with 5 additions and 1 deletions

View File

@ -177,7 +177,7 @@ class InlineUploads
end
def self.match_bbcode_img(markdown, external_src: false)
markdown.scan(/(\[img\]\s?(.+)\s?\[\/img\])/) do |match|
markdown.scan(/(\[img\]\s*([^\[\]\s]+)\s*\[\/img\])/) do |match|
if (matched_uploads(match[1]).present? && block_given?) || external_src
yield(match[0], match[1], +"![](#{PLACEHOLDER})", $~.offset(0)[0])
end

View File

@ -163,6 +163,8 @@ RSpec.describe InlineUploads do
[img]
#{upload2.url}
[/img]
[img]#{upload.url}[/img][img]#{upload2.url}[/img]
MD
expect(InlineUploads.process(md)).to eq(<<~MD)
@ -171,6 +173,8 @@ RSpec.describe InlineUploads do
![](#{upload3.short_url})
![](#{upload2.short_url})
![](#{upload.short_url})![](#{upload2.short_url})
MD
end