Module:Delink: Difference between revisions

From the Croc Wiki, the Croc encyclopedia
Jump to navigationJump to search
use pcall and mw.title.new to check for valid titles
(remove extra whitespace)
(use pcall and mw.title.new to check for valid titles)
Line 67:
local titlearea
if mw.ustring.match(s, "|") then -- Find if we're dealing with a piped link.
titlearea = mw.ustring.match(s, "^%[%[(.-)|.*%]%]")
else
titlearea = mw.ustring.match(s, "^%[%[(.-)%]%]")
end
-- ClearIf the title ofarea theis not a valid title, fragmentreturn (the sectionwhole link)string.
-- Use pcall in case we're over the expensive functions limit.
if not mw.title.makeTitle("", titlearea) then
local goodcall, title = pcall(mw.title.new, titlearea, "")
return s -- If it's not a valid link, return the whole string.
if not (goodcall and title) then
return s
end
-- Check for characters that are allowed in titles but not in wikilinks.
local other_invalid_link_strings = { '�' }
for i,v in ipairs(other_invalid_link_strings) do
Cookies help us deliver our services. By using our services, you agree to our use of cookies.

Navigation menu