Another fix for redirect function

This commit is contained in:
Kay0u 2021-11-16 21:40:04 +01:00
parent 08be399a49
commit 981960fb50
No known key found for this signature in database
GPG key ID: AAFEEB16CFA2AE2D

View file

@ -1070,8 +1070,13 @@ function redirect(url)
if not string.starts(url, "/") and not string.starts(url, "http://") and not string.starts(url, "https://") then if not string.starts(url, "/") and not string.starts(url, "http://") and not string.starts(url, "https://") then
url = "https://"..url url = "https://"..url
end end
local is_known_domain = false local is_known_domain = string.starts(url, "/")
for _, domain in ipairs(conf["domains"]) do for _, domain in ipairs(conf["domains"]) do
if is_known_domain then
break
end
-- Replace - character to %- because - is a special char for regex in lua
domain = string.gsub(domain, "%-","%%-")
is_known_domain = is_known_domain or url:match("^https?://"..domain.."/?") ~= nil is_known_domain = is_known_domain or url:match("^https?://"..domain.."/?") ~= nil
end end
if string.match(url, "(.*)\n") or not is_known_domain then if string.match(url, "(.*)\n") or not is_known_domain then