Mercurial > prosody-hg
changeset 13912:a0faff6ba853
moduleapi: Fix traceback when no host passed to :context() (thanks Menel, riau)
I don't particularly like this, but it seems to be depended on and I don't
plan to break the API at this time.
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Thu, 03 Jul 2025 10:59:17 +0100 |
| parents | 79ae4821c05e |
| children | 1bc4e7ab964c |
| files | core/moduleapi.lua |
| diffstat | 1 files changed, 5 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/core/moduleapi.lua Mon Jun 30 11:16:52 2025 +0100 +++ b/core/moduleapi.lua Thu Jul 03 10:59:17 2025 +0100 @@ -412,11 +412,14 @@ end function api:context(host) - local is_global = host == "*"; + local is_global; + if not host or host == "*" then + host, is_global = "*", true; + end if not is_global and not hosts[host] then error("Cannot create context for unknown host: "..host); end - return setmetatable({ host = host or "*", global = is_global }, { __index = self, __newindex = self }); + return setmetatable({ host = host, global = is_global }, { __index = self, __newindex = self }); end function api:add_item(key, value)
