Module:Sandbox/Erutuon: Difference between revisions

Content deleted Content added
early error if tag doesn't start with language or private-use subtag?
table of error messages
Line 361:
-- "index" is the ordinal of the subtag in which the error was found.
throw = function (self, error, index)
self.error = self.error_messages[error]
self.invalid = table.concat(self.input, "-", index)
return self:remove_unnecessary_fields()
Line 371:
return setmetatable(self, nil)
end,
error_messages = {
invalid_characters = "invalid characters",
no_language = "no language subtag",
invalid_subtag = "invalid subtag",
invalid_private_use = "length of private-use subtag out of range",
empty_private_use = "empty private-use subtag",
}
}
}
Line 423 ⟶ 431:
if not tag:find "^[A-Za-z0-9-]+$" then
return parsed_subtags:throw(
"invalid charactersinvalid_characters",
fun.indexOf(
function (tag)
Line 505 ⟶ 513:
and potential_subtags[last_matched_subtag_i + 1]:lower() ~= "x" then
if not parsed_subtags.language then
return parsed_subtags:throw("no language subtagno_language", 1)
else
return parsed_subtags:throw("invalid subtaginvalid_subtag",
last_matched_subtag_i + 1)
end
Line 514 ⟶ 522:
-- Check length of all following subtags.
if not potential_subtags[last_matched_subtag_i + 2] then
return parsed_subtags:throw("empty private-use subtagempty_private_use",
last_matched_subtag_i + 1)
end
Line 523 ⟶ 531:
if not (1 <= length and length <= 8) then
return parsed_subtags
:throw("length of private-use subtag out of rangeinvalid_private_use",
last_matched_subtag_i + 1)
end