Túto dokumentáciu [vytvoriť] [obnoviť]
Dokumentácia Dokumentácia

Dokumentácia pre tento modul zatiaľ neexistuje. Môžete ju vytvoriť na Modul:IP/Dokumentácia


Ak máte otázku k tomuto modulu, alebo potrebujete jeho rozšírenie a neviete ho správne naformátovať, pýtajte sa v diskusii k modulu. Pokiaľ je potrebné modul urgentne opraviť, obráťte sa na technickú podporu.

local getArgs = require('Module:Arguments').getArgs
local p = {}

function p.formatError(msg)
    markup = '<strong class="error">' .. msg .. '</strong>'
    markup = markup .. "[[Kategória:Chyby hlásené modulom IP]]"
    return markup
end

-- Zero pads octects of IPv4 address inside a string (e.g. "... 1.22.8.112 ..." -> "... 001.022.008.112 ...")
function p._pad(s)
    local h, a, b, c, d, t = string.match(s, "^(.-)([012]?%d?%d)%.([012]?%d?%d)%.([012]?%d?%d)%.([012]?%d?%d)(.*)$")
    if (a == nil) then
      return s
    else
      return h .. string.format("%03d.%03d.%03d.%03d", a, b, c, d) .. t
    end
end

function p.pad(frame)
    local args = getArgs(frame)
    local success, result = pcall(p._pad, args[1])
    if (not success) then
        result = p.formatError(result)
    end
    return result
end

return p