comparison core/moduleapi.lua @ 13990:cf21d285385b

core.moduleapi: Fix :context() called from a global module Because `is_global` defaults to nil, it passes trough the metatabele to the calling module, so a host context retrieved from a global module would have the .global flag be true. This causes trouble with the code retrieving the hostname in `module:http_url()`, so `http:list()` in the shell would produce host URLs like `https://*:5281/`
author Kim Alvefur <zash@zash.se>
date Wed, 05 Nov 2025 16:19:50 +0100
parents a0faff6ba853
children a124e80d3498
comparison
equal deleted inserted replaced
13989:a8aa17293d22 13990:cf21d285385b
410 end 410 end
411 return value; 411 return value;
412 end 412 end
413 413
414 function api:context(host) 414 function api:context(host)
415 local is_global; 415 local is_global = false;
416 if not host or host == "*" then 416 if not host or host == "*" then
417 host, is_global = "*", true; 417 host, is_global = "*", true;
418 end 418 end
419 if not is_global and not hosts[host] then 419 if not is_global and not hosts[host] then
420 error("Cannot create context for unknown host: "..host); 420 error("Cannot create context for unknown host: "..host);