Content deleted Content added
place invalid tag suffix in "invalid" field, use "error" to indicate both that an error was present and the type of error |
check for nil, empty, non-string, invalid characters |
||
Line 356:
end
-- A previous draft, in [[Module:Lang/sandbox]]
-- https://en.wikipedia.org/w/index.php?oldid=812819217
function p.parse_IETF(tag)
if not tag or tag == "" or type(tag) ~= "string" then
local subtags = mw.text.split(tag, "-")▼
return nil
end
-- This contains the special fields "matched_count" and "invalid".
Line 370 ⟶ 372:
-- hyphen).
local parsed_subtags = { matched_count = 0 }
if not tag:find '^[A-Za-z0-9-]+$' then
parsed_subtags.error = "invalid characters"
parsed_subtags.invalid = tag
return parsed_subtags
end
▲ local subtags = mw.text.split(tag, "-")
-- An array of patterns for each subtag, and a "type" field for the name
|