matrix_chat/validate_server.lua
joenas c3c6731d8b Breaking changes:
Removed port setting (fixes #9)
Throw errors when weird/faulty matrix url (work on #10)
Added neturl for url parsing
2017-09-12 11:30:03 +02:00

22 lines
587 B
Lua

local url = require "net.url"
function validate_server(hs_url)
u = url.parse(hs_url):normalize()
if not (u.host and u.scheme) then
return error("'"..hs_url.."' doesn't look like a valid url. Please specify scheme (http/s) and hostname")
end
if u.port and u.port == 8448 and u.scheme == 'http' then
return error("Port 8448 is for https, make sure your homeserver URL is correct")
end
if u.port and u.port == 8008 and u.scheme == 'https' then
minetest.log("warn", "Port 8008 is not https, make sure your homeserver URL is correct")
end
return hs_url
end