Commit d9027df5 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge pull request #2706 from jfut/gh-issue-2602

Remove relative_url_root from path. Fixes #2602
parents aa99660f 79b9249f
...@@ -50,6 +50,8 @@ module ExtractsPath ...@@ -50,6 +50,8 @@ module ExtractsPath
return pair unless @project return pair unless @project
# Remove relative_url_root from path
input.gsub!(/^#{Gitlab.config.gitlab.relative_url_root}/, "")
# Remove project, actions and all other staff from path # Remove project, actions and all other staff from path
input.gsub!(/^\/#{Regexp.escape(@project.path_with_namespace)}/, "") input.gsub!(/^\/#{Regexp.escape(@project.path_with_namespace)}/, "")
input.gsub!(/^\/(tree|commits|blame|blob|refs)\//, "") # remove actions input.gsub!(/^\/(tree|commits|blame|blob|refs)\//, "") # remove actions
......
...@@ -73,5 +73,28 @@ describe ExtractsPath do ...@@ -73,5 +73,28 @@ describe ExtractsPath do
extract_ref('/gitlab/gitlab-ci/tree/v2.0.0/CHANGELOG?_=12354435').should == ['v2.0.0', 'CHANGELOG'] extract_ref('/gitlab/gitlab-ci/tree/v2.0.0/CHANGELOG?_=12354435').should == ['v2.0.0', 'CHANGELOG']
end end
end end
context "with a fullpath and a relative_url_root" do
before do
Gitlab.config.gitlab.stub(relative_url_root: '/relative')
end
it "extracts a valid branch with relative_url_root" do
extract_ref('/relative/gitlab/gitlab-ci/tree/foo/bar/baz/CHANGELOG').should == ['foo/bar/baz', 'CHANGELOG']
end
it "extracts a valid tag" do
extract_ref('/relative/gitlab/gitlab-ci/tree/v2.0.0/CHANGELOG').should == ['v2.0.0', 'CHANGELOG']
end
it "extracts a valid commit SHA" do
extract_ref('/relative/gitlab/gitlab-ci/tree/f4b14494ef6abf3d144c28e4af0c20143383e062/CHANGELOG').should ==
['f4b14494ef6abf3d144c28e4af0c20143383e062', 'CHANGELOG']
end
it "extracts a timestamp" do
extract_ref('/relative/gitlab/gitlab-ci/tree/v2.0.0/CHANGELOG?_=12354435').should == ['v2.0.0', 'CHANGELOG']
end
end
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment