mirror of
https://github.com/britzl/monarch.git
synced 2025-06-27 10:27:49 +02:00
Fix message mock to properly deal with indexing of URLs
This commit is contained in:
parent
b37cb1ba79
commit
504ac9223a
20
test/msg.lua
20
test/msg.lua
@ -8,9 +8,25 @@ local recipients = {}
|
||||
|
||||
local history = {}
|
||||
|
||||
local function url_to_key(url)
|
||||
if type(url) == "string" then
|
||||
url = msg.url(url)
|
||||
end
|
||||
local ok, err = pcall(function() return url.socket end)
|
||||
if not ok then
|
||||
return url
|
||||
end
|
||||
if url.socket then
|
||||
return hash_to_hex(url.socket or hash("")) .. hash_to_hex(url.path or hash("")) .. hash_to_hex(url.fragment or hash(""))
|
||||
else
|
||||
return url
|
||||
end
|
||||
end
|
||||
|
||||
local function get_recipient(url)
|
||||
recipients[url] = recipients[url] or {}
|
||||
return recipients[url]
|
||||
local key = url_to_key(url)
|
||||
recipients[key] = recipients[key] or {}
|
||||
return recipients[key]
|
||||
end
|
||||
|
||||
local function post(url, message_id, message)
|
||||
|
Loading…
x
Reference in New Issue
Block a user