Module:Sandbox/Erutuon: Difference between revisions

Content deleted Content added
place variant tags in array if there is more than one
m easier to read
Line 486:
-- Not all potential subtags were matched. Check for private-use subtags.
-- https://tools.ietf.org/html/bcp47#section-2.2.7
-- Private-use subtags consist of "x-" followed by one or more subtagssequences of 1 to 8
-- alphanumeric characters preceded by "x-".
-- consisting of 1 to 8 alphanumeric characters.
-- Alphanumericity has already been checked.
if potential_subtags[last_matched_subtag_i + 1] =~= "x" then
-- Check length of all following subtags.
if not potential_subtags[last_matched_subtag_i + 2] then
return parsed_subtags:throw("empty private-use subtag",
last_matched_subtag_i + 1)
end
for i = last_matched_subtag_i + 2, #potential_subtags do
local length = #potential_subtags[i]
if not (1 <= length and length <= 8) then
return parsed_subtags
:throw("length of private-use subtag out of range",
last_matched_subtag_i + 1)
end
end
parsed_subtags.private_use = table.concat(potential_subtags, "-",
last_matched_subtag_i + 1)
else
return parsed_subtags:throw("invalid subtag",
last_matched_subtag_i + 1)
end
-- Check length of all following subtags.
if not potential_subtags[last_matched_subtag_i + 2] then
return parsed_subtags:throw("empty private-use subtag",
last_matched_subtag_i + 1)
end
for i = last_matched_subtag_i + 2, #potential_subtags do
local length = #potential_subtags[i]
if not (1 <= length and length <= 8) then
return parsed_subtags
:throw("length of private-use subtag out of range",
last_matched_subtag_i + 1)
end
end
parsed_subtags.private_use = table.concat(potential_subtags, "-",
last_matched_subtag_i + 1)
end