summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/controllers/projects/artifacts_controller.rb1
-rw-r--r--lib/gitlab/ci/build/artifacts/metadata.rb2
-rw-r--r--spec/lib/gitlab/ci/build/artifacts/metadata_spec.rb6
3 files changed, 6 insertions, 3 deletions
diff --git a/app/controllers/projects/artifacts_controller.rb b/app/controllers/projects/artifacts_controller.rb
index ee1b1f375dc..d11ae5bd52d 100644
--- a/app/controllers/projects/artifacts_controller.rb
+++ b/app/controllers/projects/artifacts_controller.rb
@@ -17,6 +17,7 @@ class Projects::ArtifactsController < Projects::ApplicationController
def browse
return render_404 unless build.artifacts?
@path = build.artifacts_metadata_string_path(params[:path] || './')
+ return render_404 if @path.universe.empty?
end
private
diff --git a/lib/gitlab/ci/build/artifacts/metadata.rb b/lib/gitlab/ci/build/artifacts/metadata.rb
index 5313182d55f..d5c3cd10e48 100644
--- a/lib/gitlab/ci/build/artifacts/metadata.rb
+++ b/lib/gitlab/ci/build/artifacts/metadata.rb
@@ -22,7 +22,7 @@ module Gitlab
paths, metadata = [], []
each do |line|
- next unless line =~ %r{^#{Regexp.escape(@path)}[^/\s]+/?\s}
+ next unless line =~ %r{^#{Regexp.escape(@path)}[^/\s]*/?\s}
path, meta = line.split(' ')
paths.push(path)
diff --git a/spec/lib/gitlab/ci/build/artifacts/metadata_spec.rb b/spec/lib/gitlab/ci/build/artifacts/metadata_spec.rb
index 8c648be5f02..62c86a60ac4 100644
--- a/spec/lib/gitlab/ci/build/artifacts/metadata_spec.rb
+++ b/spec/lib/gitlab/ci/build/artifacts/metadata_spec.rb
@@ -38,7 +38,8 @@ describe Gitlab::Ci::Build::Artifacts::Metadata do
it 'matches correct paths' do
expect(subject.first).
- to contain_exactly 'other_artifacts_0.1.2/doc_sample.txt',
+ to contain_exactly 'other_artifacts_0.1.2/',
+ 'other_artifacts_0.1.2/doc_sample.txt',
'other_artifacts_0.1.2/another-subdirectory/'
end
end
@@ -48,7 +49,8 @@ describe Gitlab::Ci::Build::Artifacts::Metadata do
it 'matches correct paths' do
expect(subject.first).
- to contain_exactly 'other_artifacts_0.1.2/another-subdirectory/empty_directory/',
+ to contain_exactly 'other_artifacts_0.1.2/another-subdirectory/',
+ 'other_artifacts_0.1.2/another-subdirectory/empty_directory/',
'other_artifacts_0.1.2/another-subdirectory/banana_sample.gif'
end
end