Module:Redirect/sandbox: Difference between revisions

Content deleted Content added
No edit summary
Adding a "pipe" parameter so you can choose only to change redirects that aren't part of the text
Line 110:
 
local args = getArgs(frame)
local sourceName, start, text, pipe, nowiki = args[1], args[2], args.text, args.pipe, args.nowiki
if type(sourceName) == "string" then sourceName = mw.text.trim(sourceName) or sourceName end
if type(start) == "string" then start = mw.text.trim(start) or start end
if type(pipe) == "string" then pipe = mw.text.trim(pipe) or pipe end
if type(text) ~= "string" then
Line 129 ⟶ 130:
if not(start) and link ~= " " then
newLink = getRedirect(link)
-- if the page does redirect, do it if "pipe" isn't set or a pipe is present or absent as specified
if newLink and (newLink ~= link) then
if newLink and (newLink ~= link) and ((not pipe) or (pipe == 'make') or (display and (pipe == 'yes')) or (not display and (pipe == 'no'))) then
link = warOnGsub(link, nil)
if pipe == 'make' then
if newLink and= (newLink ~=.. link)"|" then.. link
end
newLink = warOnGsub(newLink, true)
text = mw.ustring.gsub(text, link, newLink, 1) or text -- no sense looking past 1, we'll be back...