Documentation for this module may be created at Module:Resolve redirect/doc

-- USER:XUANMIEN Module:Resolve redirect
 
-- <nowiki>
 
local export = {}
local replace = mw.ustring.gsub
local find = mw.ustring.find

function export.show(content)
	if find(content, "#[Rr][Ee][Dd][Ii][Rr][Ee][Cc][Tt]") then
		content = replace(content, "\n.*", "") -- keep first line
		content = replace(content, ".+%[%[", "") -- dispose of link opening
		content = replace(content, "%]%].*", "") -- and link end
		content = replace(content, "|.*", "") -- and link titles
		content = mw.title.new(content):getContent() or ''
	end
	return content
end

return export
Community content is available under CC-BY-SA unless otherwise noted.