Fixes #2628: KB link to public interface loses HTTP type.
This commit is contained in:
parent
212e07e322
commit
a01a2f3c91
4 changed files with 20 additions and 12 deletions
|
@ -116,9 +116,8 @@ class App.KnowledgeBaseCustomAddressForm extends App.KnowledgeBaseForm
|
||||||
openSnippetsModal: (e) ->
|
openSnippetsModal: (e) ->
|
||||||
@preventDefaultAndStopPropagation(e)
|
@preventDefaultAndStopPropagation(e)
|
||||||
|
|
||||||
loader = new App.ControllerModalLoading(
|
button = e.currentTarget
|
||||||
container: @el.closest('.main')
|
button.disabled = true
|
||||||
)
|
|
||||||
|
|
||||||
@ajax(
|
@ajax(
|
||||||
id: 'knowledge_bases_init_admin'
|
id: 'knowledge_bases_init_admin'
|
||||||
|
@ -126,7 +125,7 @@ class App.KnowledgeBaseCustomAddressForm extends App.KnowledgeBaseForm
|
||||||
url: @object().manageUrl('server_snippets')
|
url: @object().manageUrl('server_snippets')
|
||||||
processData: true
|
processData: true
|
||||||
success: (data, status, xhr) =>
|
success: (data, status, xhr) =>
|
||||||
loader.hide()
|
button.disabled = false
|
||||||
|
|
||||||
new App.KnowledgeBaseServerSnippet(
|
new App.KnowledgeBaseServerSnippet(
|
||||||
container: @el.closest('.main')
|
container: @el.closest('.main')
|
||||||
|
@ -135,7 +134,7 @@ class App.KnowledgeBaseCustomAddressForm extends App.KnowledgeBaseForm
|
||||||
address_type: data.address_type
|
address_type: data.address_type
|
||||||
)
|
)
|
||||||
error: (xhr) =>
|
error: (xhr) =>
|
||||||
loader.hide()
|
button.disabled = false
|
||||||
|
|
||||||
if xhr.status != 422
|
if xhr.status != 422
|
||||||
return
|
return
|
||||||
|
|
|
@ -39,7 +39,7 @@ class KnowledgeBase::Public::CategoriesController < KnowledgeBase::Public::BaseC
|
||||||
|
|
||||||
path = help_root_path(locale: primary_locale.locale)
|
path = help_root_path(locale: primary_locale.locale)
|
||||||
|
|
||||||
redirect_to custom_path_if_needed(path, knowledge_base)
|
redirect_to custom_path_if_needed(path, knowledge_base, full: true)
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
@ -5,13 +5,20 @@ module KnowledgeBaseHelper
|
||||||
knowledge_base.send("#{layout_prefix}_layout")
|
knowledge_base.send("#{layout_prefix}_layout")
|
||||||
end
|
end
|
||||||
|
|
||||||
def custom_path_if_needed(path, knowledge_base)
|
def custom_path_if_needed(path, knowledge_base, full: false)
|
||||||
return path if knowledge_base.custom_address_matches? request
|
return path unless knowledge_base.custom_address_matches? request
|
||||||
|
|
||||||
prefix = knowledge_base.custom_address_uri&.path
|
custom_address = knowledge_base.custom_address_uri
|
||||||
return path if prefix.nil?
|
return path unless custom_address
|
||||||
|
|
||||||
path.gsub(%r{^\/help}, prefix).presence || '/'
|
output = path.gsub(%r{^\/help}, custom_address.path || '').presence || '/'
|
||||||
|
|
||||||
|
if full
|
||||||
|
fqdn = request.headers.env['SERVER_NAME']
|
||||||
|
output = "#{custom_address.scheme}://#{custom_address.host || fqdn}#{output}"
|
||||||
|
end
|
||||||
|
|
||||||
|
output
|
||||||
end
|
end
|
||||||
|
|
||||||
def translation_locale_code(translation)
|
def translation_locale_code(translation)
|
||||||
|
|
|
@ -63,7 +63,9 @@ class KnowledgeBase < ApplicationModel
|
||||||
def custom_address_uri
|
def custom_address_uri
|
||||||
return nil if custom_address.blank?
|
return nil if custom_address.blank?
|
||||||
|
|
||||||
URI("protocol://#{custom_address}")
|
scheme = Setting.get('http_type') || 'http'
|
||||||
|
|
||||||
|
URI("#{scheme}://#{custom_address}")
|
||||||
rescue URI::InvalidURIError
|
rescue URI::InvalidURIError
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue