Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2018-10-16 22:11:31 +0300
committerDouwe Maan <douwe@gitlab.com>2018-10-16 22:11:31 +0300
commit4f475b812512dfa0029c7995d1fc3057e6b0c648 (patch)
treecb433740fe05ad06a967a8695a62fe4f3d2f6739 /lib
parent1dfecf3e178d541b4e3e53619c3be969c1c051af (diff)
parent5e8f1e06b655285cda20c12593b76c84eb93ff84 (diff)
Merge branch '52650-webhook-image-urls-rewritten-incorrectly-in-issues' into 'master'
Resolve "Webhook Image URLs Rewritten Incorrectly in Issues" Closes #52650 See merge request gitlab-org/gitlab-ce!22361
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/hook_data/base_builder.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/gitlab/hook_data/base_builder.rb b/lib/gitlab/hook_data/base_builder.rb
index 4ffca356b29..1a91301e8be 100644
--- a/lib/gitlab/hook_data/base_builder.rb
+++ b/lib/gitlab/hook_data/base_builder.rb
@@ -25,6 +25,7 @@ module Gitlab
markdown_text.gsub(MARKDOWN_SIMPLE_IMAGE) do
if $~[:image]
url = $~[:url]
+ url = "#{uploads_prefix}#{url}" if url.start_with?('/uploads')
url = "/#{url}" unless url.start_with?('/')
"![#{$~[:title]}](#{Gitlab.config.gitlab.url}#{url})"
@@ -33,6 +34,16 @@ module Gitlab
end
end
end
+
+ def uploads_prefix
+ project&.full_path || ''
+ end
+
+ def project
+ return unless object.respond_to?(:project)
+
+ object.project
+ end
end
end
end