summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2018-01-12 08:14:31 +0000
committerDouwe Maan <douwe@gitlab.com>2018-01-12 08:14:31 +0000
commit57c15d5a1254ec9914bf998b6fa02f95e87177e7 (patch)
treed334486b007339fc109a57222c0b455dce5f4be9 /lib
parentd607f16fe5a1ec51eaea5811b5118b1ba48acfbc (diff)
parentd2f83a10ea52a4fcbf380ddf01685bbc6ad7ee7a (diff)
downloadgitlab-ce-57c15d5a1254ec9914bf998b6fa02f95e87177e7.tar.gz
Merge branch '41882-respect-only-path-in-relative-link-filter' into 'master'
Resolve "Attachments in e-mail notifications are using the wrong URL" Closes #41882 See merge request gitlab-org/gitlab-ce!16364
Diffstat (limited to 'lib')
-rw-r--r--lib/banzai/filter/relative_link_filter.rb15
1 files changed, 11 insertions, 4 deletions
diff --git a/lib/banzai/filter/relative_link_filter.rb b/lib/banzai/filter/relative_link_filter.rb
index 5c197afd782..f6169b2c85d 100644
--- a/lib/banzai/filter/relative_link_filter.rb
+++ b/lib/banzai/filter/relative_link_filter.rb
@@ -50,15 +50,22 @@ module Banzai
end
def process_link_to_upload_attr(html_attr)
- uri_parts = [html_attr.value]
+ path_parts = [html_attr.value]
if group
- uri_parts.unshift(relative_url_root, 'groups', group.full_path, '-')
+ path_parts.unshift(relative_url_root, 'groups', group.full_path, '-')
elsif project
- uri_parts.unshift(relative_url_root, project.full_path)
+ path_parts.unshift(relative_url_root, project.full_path)
end
- html_attr.value = File.join(*uri_parts)
+ path = File.join(*path_parts)
+
+ html_attr.value =
+ if context[:only_path]
+ path
+ else
+ URI.join(Gitlab.config.gitlab.base_url, path).to_s
+ end
end
def process_link_to_repository_attr(html_attr)