diff --git a/deps/coro-websocket.lua b/deps/coro-websocket.lua index 8841617..a3ea52a 100644 --- a/deps/coro-websocket.lua +++ b/deps/coro-websocket.lua @@ -19,7 +19,10 @@ local websocketCodec = require('websocket-codec') local net = require('coro-net') local function parseUrl(url) - local protocol, host, port, pathname = string.match(url, "^(wss?)://([^:/]+):?(%d*)(/?[^#?]*)") + local protocol, host, port, pathname = string.match(url, "^(wss?)://([^:/]+):?(%d*)(/?[^#]*)") + if not protocol or not host or host == "" then + return nil, "Invalid URL" + end local tls if protocol == "ws" then port = tonumber(port) or 80 @@ -30,6 +33,9 @@ local function parseUrl(url) else return nil, "Sorry, only ws:// or wss:// protocols supported" end + if pathname == "" then + pathname = "/" + end return { host = host, port = port,