diff --git a/app/uploaders/file_uploader.rb b/app/uploaders/file_uploader.rb index 25d879ff449..730153a4740 100644 --- a/app/uploaders/file_uploader.rb +++ b/app/uploaders/file_uploader.rb @@ -32,6 +32,10 @@ class FileUploader < CarrierWave::Uploader::Base File.join("/uploads", @secret, file.filename) end + def to_markdown + to_h[:markdown] + end + def to_h filename = image? ? self.file.basename : self.file.filename escaped_filename = filename.gsub("]", "\\]") diff --git a/lib/gitlab/gfm/reference_rewriter.rb b/lib/gitlab/gfm/reference_rewriter.rb index 47e1aa67976..78d7a4f27cf 100644 --- a/lib/gitlab/gfm/reference_rewriter.rb +++ b/lib/gitlab/gfm/reference_rewriter.rb @@ -46,7 +46,7 @@ module Gitlab end def needs_rewrite? - !(@text =~ @pattern).nil? + @text =~ @pattern end private diff --git a/lib/gitlab/gfm/uploads_rewriter.rb b/lib/gitlab/gfm/uploads_rewriter.rb index bdf054a6192..2e61f799a03 100644 --- a/lib/gitlab/gfm/uploads_rewriter.rb +++ b/lib/gitlab/gfm/uploads_rewriter.rb @@ -23,7 +23,7 @@ module Gitlab return markdown unless file.try(:exists?) new_uploader.store!(file) - new_uploader.to_h[:markdown] + new_uploader.to_markdown end end