Anonymous user
Module:IPAddress: Difference between revisions
From the Croc Wiki, the Croc encyclopedia
Jump to navigationJump to search
update from Module:IPAddress/sandbox with new isIpOrRange function per Module talk:IPAddress#isIpOrRange
m (Changed protection level for "Module:IPAddress": integrating to local interface via MediaWiki:Newarticletext ([Edit=Require administrator access] (indefinite) [Move=Require administrator access] (indefinite))) |
(update from Module:IPAddress/sandbox with new isIpOrRange function per Module talk:IPAddress#isIpOrRange) |
||
Line 11:
function _isIpV6( s )
end
function _isIpV4( s )
end
function _isIp( s )
end
Line 46:
function p.isIpV4(frame) return _isIpV4( frame.args[ 1 ] ) and "1" or "0" end
function p.isIp(frame) return _isIp( frame.args[ 1 ] ) or "" end
function p.isIpOrRange(frame)
-- {{#invoke:IPAddress|isIpOrRange|x}} → 'ip' (IPv4/IPv6) or 'range' (CIDR IPv4/IPv6) or '' (invalid)
local modip = require('Module:IP')
local s = frame.args[1]
local success, ip = pcall(modip.IPAddress.new, s)
if success then
return 'ip'
end
success, ip = pcall(modip.Subnet.new, s)
if success then
return 'range'
end
return ''
end
return p
|