Module:Delink: Difference between revisions

From the Croc Wiki, the Croc encyclopedia
Jump to navigationJump to search
Content added Content deleted
(better decoding support)
(Replace hardcoded namespaces with namespace lookups)
Line 57: Line 57:
-- Check for categories, interwikis, and files.
-- Check for categories, interwikis, and files.
local colonprefix = mw.ustring.match(result, "%[%[(.-):.*%]%]") or "" -- Get the text before the first colon.
local colonprefix = mw.ustring.match(result, "%[%[(.-):.*%]%]") or "" -- Get the text before the first colon.
local ns = mw.site.namespaces[colonprefix] -- see if this is a known namespace
if mw.language.isKnownLanguageTag(colonprefix)
if mw.language.isKnownLanguageTag(colonprefix)
or ( ns and ( ns.canonicalName == "File" or ns.canonicalName == "Category" ) ) then
or mw.ustring.match(colonprefix, "^[Cc]ategory$")
or mw.ustring.match(colonprefix, "^[Ff]ile$")
or mw.ustring.match(colonprefix, "^[Ii]mage$") then
return ""
return ""
end
end