summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorNick Thomas <nick@gitlab.com>2017-10-20 23:38:15 +0100
committerNick Thomas <nick@gitlab.com>2017-10-20 23:38:35 +0100
commit3c0be3cd41a72925678df457b040a559a4ba01ee (patch)
tree585d0b83b1fba262074a4baf5bee9172c8d94647 /app
parente1122c9f6daff16b900a0837d25789e1e5bdc56c (diff)
downloadgitlab-ce-3c0be3cd41a72925678df457b040a559a4ba01ee.tar.gz
Fix the external URLs generated for online view of HTML artifacts
Diffstat (limited to 'app')
-rw-r--r--app/models/ci/artifact_blob.rb17
1 files changed, 11 insertions, 6 deletions
diff --git a/app/models/ci/artifact_blob.rb b/app/models/ci/artifact_blob.rb
index 8b66531ec7b..ec56cc53aea 100644
--- a/app/models/ci/artifact_blob.rb
+++ b/app/models/ci/artifact_blob.rb
@@ -2,7 +2,7 @@ module Ci
class ArtifactBlob
include BlobLike
- EXTENTIONS_SERVED_BY_PAGES = %w[.html .htm .txt .json].freeze
+ EXTENSIONS_SERVED_BY_PAGES = %w[.html .htm .txt .json].freeze
attr_reader :entry
@@ -36,17 +36,22 @@ module Ci
def external_url(project, job)
return unless external_link?(job)
- components = project.full_path_components
- components << "-/jobs/#{job.id}/artifacts/file/#{path}"
- artifact_path = components[1..-1].join('/')
+ full_path_parts = project.full_path_components
+ top_level_group = full_path_parts.shift
- "#{pages_config.protocol}://#{components[0]}.#{pages_config.host}/#{artifact_path}"
+ artifact_path = [
+ '-', *full_path_parts, '-',
+ 'jobs', job.id,
+ 'artifacts', path
+ ].join('/')
+
+ "#{pages_config.protocol}://#{top_level_group}.#{pages_config.host}/#{artifact_path}"
end
def external_link?(job)
pages_config.enabled &&
pages_config.artifacts_server &&
- EXTENTIONS_SERVED_BY_PAGES.include?(File.extname(name)) &&
+ EXTENSIONS_SERVED_BY_PAGES.include?(File.extname(name)) &&
job.project.public?
end