Commit 79b9249ff44c5ccbef44a8d9420a3fff369d932a
1 parent
65737bd5
Exists in
master
and in
4 other branches
Remove relative_url_root from path. Fixes #2602
Files and Commits render a 404 when running with relative_url_root.
Showing
2 changed files
with
25 additions
and
0 deletions
Show diff stats
lib/extracts_path.rb
| ... | ... | @@ -50,6 +50,8 @@ module ExtractsPath |
| 50 | 50 | |
| 51 | 51 | return pair unless @project |
| 52 | 52 | |
| 53 | + # Remove relative_url_root from path | |
| 54 | + input.gsub!(/^#{Gitlab.config.gitlab.relative_url_root}/, "") | |
| 53 | 55 | # Remove project, actions and all other staff from path |
| 54 | 56 | input.gsub!(/^\/#{Regexp.escape(@project.path_with_namespace)}/, "") |
| 55 | 57 | input.gsub!(/^\/(tree|commits|blame|blob|refs)\//, "") # remove actions | ... | ... |
spec/lib/extracts_path_spec.rb
| ... | ... | @@ -73,5 +73,28 @@ describe ExtractsPath do |
| 73 | 73 | extract_ref('/gitlab/gitlab-ci/tree/v2.0.0/CHANGELOG?_=12354435').should == ['v2.0.0', 'CHANGELOG'] |
| 74 | 74 | end |
| 75 | 75 | end |
| 76 | + | |
| 77 | + context "with a fullpath and a relative_url_root" do | |
| 78 | + before do | |
| 79 | + Gitlab.config.gitlab.stub(relative_url_root: '/relative') | |
| 80 | + end | |
| 81 | + | |
| 82 | + it "extracts a valid branch with relative_url_root" do | |
| 83 | + extract_ref('/relative/gitlab/gitlab-ci/tree/foo/bar/baz/CHANGELOG').should == ['foo/bar/baz', 'CHANGELOG'] | |
| 84 | + end | |
| 85 | + | |
| 86 | + it "extracts a valid tag" do | |
| 87 | + extract_ref('/relative/gitlab/gitlab-ci/tree/v2.0.0/CHANGELOG').should == ['v2.0.0', 'CHANGELOG'] | |
| 88 | + end | |
| 89 | + | |
| 90 | + it "extracts a valid commit SHA" do | |
| 91 | + extract_ref('/relative/gitlab/gitlab-ci/tree/f4b14494ef6abf3d144c28e4af0c20143383e062/CHANGELOG').should == | |
| 92 | + ['f4b14494ef6abf3d144c28e4af0c20143383e062', 'CHANGELOG'] | |
| 93 | + end | |
| 94 | + | |
| 95 | + it "extracts a timestamp" do | |
| 96 | + extract_ref('/relative/gitlab/gitlab-ci/tree/v2.0.0/CHANGELOG?_=12354435').should == ['v2.0.0', 'CHANGELOG'] | |
| 97 | + end | |
| 98 | + end | |
| 76 | 99 | end |
| 77 | 100 | end | ... | ... |