Skip to content

Commit af52475

Browse files
committed
hack to resolve base tag conflicting with openapi explorer by not inserting the tag for that page
openapi explorer uses replaceState (pushState in later versions) with anchor only, but this doesn't work with base tag, as anchor is added to the base url instead of current url. So don't insert the tag on exploror page
1 parent a6aac70 commit af52475

3 files changed

Lines changed: 6 additions & 2 deletions

File tree

app/controllers/api_docs_controller.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,7 @@ class APIDocsController < ApplicationController
3636

3737
def index
3838
render_404 unless Setting.apiv3_docs_enabled?
39+
40+
render locals: { skip_base_tag: true }
3941
end
4042
end

app/views/layouts/_common_head.html.erb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
<% relative_url_root = OpenProject::Configuration["rails_relative_url_root"] || "" %>
77
<meta name="app_title" content="<%= page_title(*html_title_parts) %>">
88
<meta name="app_base_path" content="<%= relative_url_root %>">
9-
<base href="<%= relative_url_root %>/">
9+
<% unless local_assigns[:skip_base_tag] %>
10+
<base href="<%= relative_url_root %>/">
11+
<% end %>
1012
<% if @project %>
1113
<meta name="current_project"
1214
data-project-name="<%= h @project.name %>"

app/views/layouts/base.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ See COPYRIGHT and LICENSE files for more details.
3232
xml:lang="<%= I18n.locale.to_s %>"
3333
class="<%= "in_modal" unless show_decoration %>">
3434
<head>
35-
<%= render partial: "layouts/common_head" %>
35+
<%= render partial: "layouts/common_head", locals: local_assigns %>
3636
<!-- project specific tags -->
3737
<%= call_hook :view_layouts_base_html_head %>
3838
<!-- page specific tags -->

0 commit comments

Comments
 (0)