七日内新公告:全站维护公告
  • 你好~!欢迎来到萌娘百科镜像站!如需查看或编辑,请联系本站管理员注册账号。
  • 本镜像站和其他萌娘百科的镜像站无关,请注意分别。

Module:RedirectTarget

猛汉♂百科,万男皆可猛的百科全书!转载请标注来源页面的网页链接,并声明引自猛汉百科。内容不可商用。
跳到导航 跳到搜索
Template-info.svg 模块文档  [创建] [刷新]
local getRedirectTarget = function(title)
    if title == nil then return nil
    else
        local target = nil
        local temp = title
        repeat
            target = temp
            temp = temp.redirectTarget
        until not temp
        return target
    end
end

return {
    main = function(frame)
        local args = frame.args
        local title = mw.text.trim(args[1] or "")
        if mw.isSubsting() then
            local success, target = pcall(getRedirectTarget, mw.title.new(title))
            if success and target then
                return tostring(target)
            else
                return title
            end
        else return title
        end
    end
}