FIX get site url bug with setting api
This commit is contained in:
parent
e638dccfa5
commit
0b6ebb7b36
|
@ -41,18 +41,17 @@ class SettingsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_site_url(key, value)
|
def get_site_url(key, value)
|
||||||
url = reset_site_url(value)
|
key.to_s === "url" ? append_http(reset_site_url(value)) : reset_site_url(value)
|
||||||
key.to_s === "url" && !value.to_s.start_with?("http") ? [request.protocol, request.host_with_port, value].join('') : url
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def reset_site_url(url)
|
def reset_site_url(url)
|
||||||
return url unless url.to_s.include?("current_user")
|
return url unless url.to_s.include?("current_user")
|
||||||
|
|
||||||
split_arr = url.split('current_user')
|
split_arr = url.split('current_user')
|
||||||
split_arr.length > 1 ? split_arr.join(current_user&.login) : (split_arr << current_user&.login).join('')
|
split_arr.length > 1 ? split_arr.join(current_user&.login) : (split_arr << current_user&.login).join('')
|
||||||
end
|
end
|
||||||
|
|
||||||
def append_http(url)
|
def append_http(url)
|
||||||
url.to_s.start_with?("http") ? url : [request.protocol, request.host_with_port, url].join('')
|
url.to_s.start_with?("http") ? url : [request.protocol, request.host_with_port, url].join('')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue