Better base url handling

This commit is contained in:
Nick Bisby 2019-04-19 22:09:48 -05:00
parent 4210d9e386
commit 38a7ed4079
No known key found for this signature in database
GPG Key ID: F6E0C4E6D0B5EB36

View File

@ -94,23 +94,29 @@ function get_base_url()
base = get_setting("server")
port = get_setting("port")
if base.instr(0, "http") <> 0
protocol = "http"
if port = "443" or port = "8920"
protocol = protocol + "s"
if base.right(1) = "/"
base = base.left(base.len() - 1)
end if
if base.left(4) <> "http"
if server_is_https()
protocol = "https://"
else
protocol = "http://"
end if
protocol = protocol + "://"
base = protocol + base
end if
if port <> "" and port <> invalid then
base = base + ":" + port
end if
return base
end function
function server_is_https() as Boolean
server = get_setting("server")
port = get_setting("port")
i = server.Instr(":")
@ -123,6 +129,11 @@ function server_is_https() as Boolean
if protocol = "https" then
return True
end if
if port = "443" or port = "8920"
return True
end if
return False
end function