diff --git a/CHANGELOG b/CHANGELOG index 822fa4be56586b53086a9e939f20bac7436960fd..b07b7da3300dc90052b50cef418b205ea57b2799 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -36,6 +36,7 @@ v 8.8.0 (unreleased) v 8.7.4 - Fix always showing build notification message when switching between merge requests + - Fix links on wiki pages for relative url setups. !4026 (Artem Sidorenko) v 8.7.3 - Emails, Gitlab::Email::Message, Gitlab::Diff, and Premailer::Adapter::Nokogiri are now instrumented diff --git a/app/models/project_wiki.rb b/app/models/project_wiki.rb index 7c1a61bb0bfcb99a8df8ae2751b7aced85da5f11..c91cb70ae250773059218ebbeebb6d8968125be9 100644 --- a/app/models/project_wiki.rb +++ b/app/models/project_wiki.rb @@ -40,7 +40,7 @@ def http_url_to_repo end def wiki_base_path - ["/", @project.path_with_namespace, "/wikis"].join('') + [Gitlab.config.gitlab.url, "/", @project.path_with_namespace, "/wikis"].join('') end # Returns the Gollum::Wiki object. diff --git a/lib/gitlab/url_builder.rb b/lib/gitlab/url_builder.rb index 2bbbd3074e86f7fbe3bc9160ea175468391c9f89..67a09d5abf585ae61b337a4ec67083606571fa87 100644 --- a/lib/gitlab/url_builder.rb +++ b/lib/gitlab/url_builder.rb @@ -62,7 +62,7 @@ def note_url end def wiki_page_url - "#{Gitlab.config.gitlab.url}#{object.wiki.wiki_base_path}/#{object.slug}" + "#{object.wiki.wiki_base_path}/#{object.slug}" end end end diff --git a/spec/lib/gitlab/url_builder_spec.rb b/spec/lib/gitlab/url_builder_spec.rb index bf11472407a89d9d41b891a2586c8ea1e65281ae..c8d3bc0139505903e8150e00ef11ce7e5116aa05 100644 --- a/spec/lib/gitlab/url_builder_spec.rb +++ b/spec/lib/gitlab/url_builder_spec.rb @@ -112,7 +112,7 @@ wiki_page = build(:wiki_page) url = described_class.build(wiki_page) - expect(url).to eq "#{Gitlab.config.gitlab.url}#{wiki_page.wiki.wiki_base_path}/#{wiki_page.slug}" + expect(url).to eq "#{Gitlab.config.gitlab.url}/#{wiki_page.wiki.project.path_with_namespace}/wikis/#{wiki_page.slug}" end end end diff --git a/spec/models/project_wiki_spec.rb b/spec/models/project_wiki_spec.rb index 532e3f013fd0aa692d77e84ba88c37d753c757f6..ea659f417f2f07df400670f8e3b49978f640c5be 100644 --- a/spec/models/project_wiki_spec.rb +++ b/spec/models/project_wiki_spec.rb @@ -38,7 +38,9 @@ describe "#wiki_base_path" do it "returns the wiki base path" do - wiki_base_path = "/#{project.path_with_namespace}/wikis" + gitlab_url = Gitlab.config.gitlab.url + wiki_base_path = "#{gitlab_url}/#{project.path_with_namespace}/wikis" + expect(subject.wiki_base_path).to eq(wiki_base_path) end end