| This module depends on the following other modules: |
This module is used by AnomieBOT's User:AnomieBOT/Auto-G8 template.
Usage
[edit]{{#invoke:User:AnomieBOT/Auto-G8|check}}
Applies checks of the User:AnomieBOT/Auto-G8 usage to flag redirects that may need attention. Generally uses urn links to do the flagging, see Special:LinkSearch/urn:x-anomiebot-auto-g8-.
-- A module used by [[User:AnomieBOT/Auto-G8]]
local p = {}
function p.check( frame )
local curtitle = mw.title.getCurrentTitle()
local args = require("Module:Arguments").getArgs(frame)
if ( args[1] or "endash" ) == "endash" then
return p.check_endash( args, curtitle, frame )
end
return ''
end
function urn( v )
return '<span class="plainlinks" style="display: none;">[urn:x-anomiebot-auto-g8-' .. v .. ' <span></span>]</span>';
end
function replace_endashes( title )
return mw.ustring.gsub( title, '[–]', '-' )
end
function p.check_endash( args, curtitle, frame )
local target = args.target or ''
local targettitle = mw.title.new( target )
-- Target title with endashes replaced needs to match the current page's title.
if target == curtitle.fullText or replace_endashes( target ) ~= curtitle.fullText then
return urn( 'mismatch:endash' )
end
-- Unnecessarily bypassed double redirect? i.e. redirect is to a matching endash-containing title and the target is a redirect to that same title.
if curtitle.redirectTarget and replace_endashes( curtitle.redirectTarget.prefixedText ) == curtitle.prefixedText and
targettitle.redirectTarget and mw.title.equals( curtitle.redirectTarget, targettitle.redirectTarget )
then
return urn( 'unnecessarily-bypassed-double-redirect:endash' )
end
return ''
end
return p