Commit 9a748ec1 authored by Markus Koller's avatar Markus Koller

Fix relative URL root in wiki_base_path

This was a bug introduced in fe5533a7.

Previously we were building the path manually and had to also include
`Gitlab.config.gitlab.relative_url_root`, but since we're using route
helpers now it's already included via `default_url_options`, which
resulted in a duplicated root in the URL.
parent bfc4c29b
......@@ -205,7 +205,7 @@ class Wiki
end
def wiki_base_path
Gitlab.config.gitlab.relative_url_root + web_url(only_path: true).sub(%r{/#{Wiki::HOMEPAGE}\z}, '')
web_url(only_path: true).sub(%r{/#{Wiki::HOMEPAGE}\z}, '')
end
private
......
---
title: Fix relative URL root in wiki_base_path
merge_request: 33841
author:
type: fixed
......@@ -63,7 +63,7 @@ describe Banzai::Pipeline::WikiPipeline do
'when GitLab is hosted at a relative URL' => '/nested/relative/gitlab' }.each do |test_name, relative_url_root|
context test_name do
before do
allow(Gitlab.config.gitlab).to receive(:relative_url_root).and_return(relative_url_root)
allow(Rails.application.routes).to receive(:default_url_options).and_return(script_name: relative_url_root)
end
describe "linking to pages within the wiki" do
......
......@@ -32,6 +32,13 @@ RSpec.shared_examples 'wiki model' do
it 'returns the wiki base path' do
expect(subject.wiki_base_path).to eq("#{wiki_container.web_url(only_path: true)}/-/wikis")
end
it 'includes the relative URL root' do
allow(Rails.application.routes).to receive(:default_url_options).and_return(script_name: '/root')
expect(subject.wiki_base_path).to start_with('/root/')
expect(subject.wiki_base_path).not_to start_with('/root/root')
end
end
describe '#wiki' do
......
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