Nicht angemeldeter Benutzer - Bearbeiten von Seiten ist nur als angemeldeter Benutzer möglich.
Änderungen
Zur Navigation springen
Zur Suche springen
Zeile 5:
Zeile 5:
− +
Zeile 24:
Zeile 24:
− +
Zeile 32:
Zeile 32:
− +
− -- return a table to allow the functions to be called from templates+
− return {+
− ["isIpV6"] = function( frame ) return isIpV6( frame.args[ 1 ] ) and "1" or "0" end,+
− ["isIpV4"] = function( frame ) return isIpV4( frame.args[ 1 ] ) and "1" or "0" end,+
− ["isIp"] = function( frame ) return isIp( frame.args[ 1 ] ) or "" end+
− }+
+
Modify to return object instead of table (convention, works with unit test framework)
]]
]]
function isIpV6( s )
function _isIpV6( s )
local dcolon, groups
local dcolon, groups
if type( s ) ~= "string"
if type( s ) ~= "string"
end
end
function isIpV4( s )
function _isIpV4( s )
local function legal( n ) return ( tonumber( n ) or 256 ) < 256 end-- in lua 0 is true!
local function legal( n ) return ( tonumber( n ) or 256 ) < 256 end-- in lua 0 is true!
end
end
function isIp( s )
function _isIp( s )
return isIpV4( s ) and "4" or isIpV6( s ) and "6"
return isIpV4( s ) and "4" or isIpV6( s ) and "6"
end
end
local p = {}
function p.isIpV6(frame) return _isIpV6( frame.args[ 1 ] ) and "1" or "0" end
function p.isIpV4(frame) return _isIpV4( frame.args[ 1 ] ) and "1" or "0" end
function p.isIp(frame) return _isIp( frame.args[ 1 ] ) and "1" or "0" end
return p