luci: format code

This commit is contained in:
xiaorouji 2023-04-18 17:39:37 +08:00 committed by sbwml
parent 022688249d
commit 8848f801b6

View File

@ -615,38 +615,38 @@ function parseURL(url)
if not url or url == "" then if not url or url == "" then
return nil return nil
end end
local pattern = "^(%w+)://" local pattern = "^(%w+)://"
local protocol = url:match(pattern) local protocol = url:match(pattern)
if not protocol then if not protocol then
--error("Invalid URL: " .. url) --error("Invalid URL: " .. url)
return nil return nil
end end
local auth_host_port = url:sub(#protocol + 4) local auth_host_port = url:sub(#protocol + 4)
local auth_pattern = "^([^@]+)@" local auth_pattern = "^([^@]+)@"
local auth = auth_host_port:match(auth_pattern) local auth = auth_host_port:match(auth_pattern)
local username, password local username, password
if auth then if auth then
username, password = auth:match("^([^:]+):([^:]+)$") username, password = auth:match("^([^:]+):([^:]+)$")
auth_host_port = auth_host_port:sub(#auth + 2) auth_host_port = auth_host_port:sub(#auth + 2)
end end
local host, port = auth_host_port:match("^([^:]+):(%d+)$") local host, port = auth_host_port:match("^([^:]+):(%d+)$")
if not host or not port then if not host or not port then
--error("Invalid URL: " .. url) --error("Invalid URL: " .. url)
return nil return nil
end end
return { return {
protocol = protocol, protocol = protocol,
username = username, username = username,
password = password, password = password,
host = host, host = host,
port = tonumber(port) port = tonumber(port)
} }
end end
local default_file_tree = { local default_file_tree = {