Comparison

core/moduleapi.lua @ 12095:c1d2bc6603ae

moduleapi: Support stripping of multi-word from module names The goal is to allow module:provides("foo-bar") with a mod_foo_bar_ prefix being stripped. It will break any existing modules that use a prefix and have hyphens instead of underscores. No such modules are known.
author Matthew Wild <mwild1@gmail.com>
date Wed, 22 Dec 2021 14:40:42 +0000
parent 12002:cbed7d8d8f35
child 12253:57d35fcde488
comparison
equal deleted inserted replaced
12094:84fd6a79cda7 12095:c1d2bc6603ae
353 end 353 end
354 if not item.name then 354 if not item.name then
355 local item_name = self.name; 355 local item_name = self.name;
356 -- Strip a provider prefix to find the item name 356 -- Strip a provider prefix to find the item name
357 -- (e.g. "auth_foo" -> "foo" for an auth provider) 357 -- (e.g. "auth_foo" -> "foo" for an auth provider)
358 if item_name:find(name.."_", 1, true) == 1 then 358 if item_name:find((name:gsub("%-", "_")).."_", 1, true) == 1 then
359 item_name = item_name:sub(#name+2); 359 item_name = item_name:sub(#name+2);
360 end 360 end
361 item.name = item_name; 361 item.name = item_name;
362 end 362 end
363 item._provided_by = self.name; 363 item._provided_by = self.name;