Module:CheckIP

From Wikiquote
Jump to navigation Jump to search

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

local exports = {};

function exports.main(frame)
    local name = frame.args["name"];
    local IPv4 = name:match(".-(%d*%.%d*%.%d*%.%d*)");
    local IPv6 = name:match(".-[0-9a-fA-F:]*:[0-9a-fA-F:]*/?%d?%d?%d?$");
    if IPv6 == nil then
        return IPv4;
    else
        return IPv6;
    end
end

return exports;