Module:Redirect for

--Copied from Module:Redirect-distinguish by User:Nihiltres local mHatnote = require('Module:Hatnote') local mHatlist = require('Module:Hatnote list') local mArguments --initialize lazily local mTableTools = require('Module:TableTools') local p = {}

function p.redirectFor (frame) mArguments = require('Module:Arguments') local args = mArguments.getArgs(frame) return p._redirectFor(args) end

function p._redirectFor(args) if not args[1] then return mHatnote.makeWikitextError(			'no redirect supplied',			'Template:Redirect for',			args.category		) end local redirectTitle = mw.title.new(args[1]) if redirectTitle and redirectTitle.exists then if not redirectTitle.isRedirect then args[1] = args[1] .. ''		end elseif not string.match(args[1], 'REDIRECT%d+') and not args[1] == 'TERM' then args[1] = args[1] .. ''	end if not args[2] then return mHatnote.makeWikitextError(			'no page to be pointed to supplied',			'Template:Redirect for',			args.category		) end args = mTableTools.compressSparseArray(args) --Assignment by removal here makes for convenient concatenation later local redirect = table.remove(args, 1) local text = string.format(		'"%s" redirects here. You may be looking for %s.',		redirect,		mHatlist.orList(args, true)	) return mHatnote._hatnote(text) end

return p