Changeset

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
parents 12094:84fd6a79cda7
children 12096:dfb29b5b0a57
files core/moduleapi.lua
diffstat 1 files changed, 1 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/core/moduleapi.lua	Tue Dec 21 21:23:01 2021 +0100
+++ b/core/moduleapi.lua	Wed Dec 22 14:40:42 2021 +0000
@@ -355,7 +355,7 @@
 		local item_name = self.name;
 		-- Strip a provider prefix to find the item name
 		-- (e.g. "auth_foo" -> "foo" for an auth provider)
-		if item_name:find(name.."_", 1, true) == 1 then
+		if item_name:find((name:gsub("%-", "_")).."_", 1, true) == 1 then
 			item_name = item_name:sub(#name+2);
 		end
 		item.name = item_name;