Module:Exist not redirect/sandbox
Appearance
(Redirected from Module:ExistNotRedirect/sandbox)
| This is the module sandbox page for Module:Exist not redirect (diff). |
| This Lua module is used on approximately 74,000 pages and changes may be widely noticed. Test changes in the module's /sandbox or /testcases subpages, or in your own module sandbox. Consider discussing changes on the talk page before implementing them. |
Implements {{Exist not redirect}}
local p = {}
function p.main(args)
local myArgs = mw.getCurrentFrame():getParent().args
local myPageName = myArgs[1]
local forceFileOnly = myArgs.forcefile -- force File: namespace check only
local displayLink = myArgs.link -- option to display link (e.g. [[Japan]] instead of Japan)
if not myPageName or myPageName == "" then
return ""
end
local myPageTitle = mw.title.makeTitle("", myPageName)
if not myPageTitle then
error("Invalid page title passed, MediaWiki cannot understand it", 1)
end
if myPageTitle.exists
or not forceFileOnly and myPageTitle.file and myPageTitle.file.exists
then
if not myPageTitle.isRedirect then
if displayLink then
return "[[" .. myArgs[1] .. "]]"
else
return myArgs[1]
end
end
end
return ""
end
return p