Module:Shortcut: Difference between revisions

allow output if no shortcuts are set but msg is present
Enwikipedia>Mr. Stradivarius
(fix error message)
Enwikipedia>Mr. Stradivarius
(allow output if no shortcuts are set but msg is present)
Line 17:
local nShortcuts = #shortcuts
 
-- Check that we have something to display
-- Validate shortcuts
if nShortcuts < 1 and not options.msg then
return nil
end
else
 
for i, shortcut in ipairs(shortcuts) do
-- Validate shortcuts
if type(shortcut) ~= 'string' or #shortcut < 1 then
for i, shortcut in ipairs(shortcuts) do
error(string.format(
'if type(shortcut) #%d~= was'string' invalidor (shortcuts#shortcut must< be strings of '1 ..then
error(string.format(
'at least one character in length)'
'shortcut #%d was invalid (shortcuts must be strings of ' ..
), 2)
'at least one character in length)'
end
), 2)
end
end
Line 82 ⟶ 83:
 
-- Error category
if shortcuts[1] then
do
local title = mw.title.new(shortcuts[1])
if not title or not title.exists then