Module:Redirect: Difference between revisions
handle apostrophes and other characters escaped by {{TALKPAGENAME}}, per protected edit request by User:Jackmcbarn
(extend the pattern to match a colon after the "REDIRECT" text) |
(handle apostrophes and other characters escaped by {{TALKPAGENAME}}, per protected edit request by User:Jackmcbarn) |
||
Line 41: | Line 41: | ||
-- in case we are over the expensive function count limit. | -- in case we are over the expensive function count limit. | ||
local noError, rpage = pcall(mw.title.new, rname) | local noError, rpage = pcall(mw.title.new, rname) | ||
if not noError or | if not noError or not rpage then | ||
-- mw.title.new failed, so use the passed page name. | |||
return mw.ustring.format(bracket, | return mw.ustring.format(bracket, rname) | ||
elseif not rpage.isRedirect then | |||
-- the page is not a redirect, so use the normalized name of the page we | |||
-- were given. | |||
return mw.ustring.format(bracket, rpage.prefixedText) | |||
end | end | ||