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