Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion deps/coro-websocket.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down