模組:RedirectCheck

local keywords = {
	"重定向",
	"redirect",
	"重新導向"
}
local enlang = mw.language.new("en")

local p = {}

function p.main(frame)
	local pagename = frame
	if type(frame) ~= "string" then
		pagename = frame.args[1]
	end
	local titleobject = mw.title.new(pagename)
	if not titleobject.exists then
		mw.log("Given page does not exist!")
		return pagename
	end
	local pagecontent = enlang:lc(mw.text.trim(titleobject:getContent(),"%n"))
	mw.log("Processed PageContent: " .. pagecontent)
	for _,y in pairs(keywords) do
		local matchresult = pagecontent:match("#" .. y .. " %[%[(%S+)]]")
		if matchresult then return matchresult end
		mw.log("Match " .. y .. " failed")
	end
	return pagename
end

return p