Module:Sandbox/Rich Farmbrough/cross-namespace

local p = {}

function p.test(frame) if (not isRedirect) then return "" end local tospace  = "" __, tospace    =  mw.string.find (mw.string.lower(getContent), "#redirect:?\s*\[\[(talk|(portal|template....)([_ ]+talk))?:")

if (tospace=="") then tospace="article space" end --  else  tospace   = mw.string.lower (tospace) end

local fromspace = "" fromspace      = mw.string.find (PageTitle, "#redirect:?\s*\[\[(talk|(portal|template....)([_ ]+talk)?:")

if (fromspace=="") then fromspace="article space " else fromspace = mw.string.lower(fromspace) end

if (fromspace == tospace) then return "[{Category:Pages incorrectly tagged as cross-namespace redirects]] .. fromspace .. tospace" end

-- Maybe -- rv = -- and check cat exists - if not add a tracking cat. -- Or  rv = "" -- Or both return rv end

return p