local fn check_modname_prefix(name) {
	if name:sub(1,1) == ":" {
		-- If the name starts with a colon, we can skip the modname prefix
		-- mechanism.
		return name:sub(2)
	} else {
		-- Enforce that the name starts with the correct mod name.
		local modname = minetest.get_current_modname()
		if modname == nil {
			--modutil.log.info("current_modname is nil")
			modname=name:split(":")[1]
		}
		local expected_prefix = modname .. ":"
		if name:sub(1, #expected_prefix) ~= expected_prefix {
			error("Name " .. name .. " does not follow naming conventions: " ..
				"\"" .. expected_prefix .. "\" or \":\" prefix required")
		}

		-- Enforce that the name only contains letters, numbers and underscores.
		local subname = name:sub(#expected_prefix+1)
		if subname:find("[^%w_]") {
			error("Name " .. name .. " does not follow naming conventions: " ..
				"contains unallowed characters")
		}

		return name
	}
}

return check_modname_prefix
