Module:Sandbox/Johnuniq/ip

-- Try catching error from Module:IP from merge proposal at -- Wikipedia:Templates_for_discussion/Log/2018_June_19#Module:IP -- See results on talk page.

local IP = require('Module:IP') local IPAddress = IP.IPAddress

local function main(frame) local results = {} for i, ipstr in ipairs({		'',		'junk',		'1.2.3.255',		'1.2.3.256',		'1:2:3:4:1FFF:ffff:ffff:ffff',		'1:2:3:4:1800::',		'0.0.0.0',		'0:0:0:0:0:0:0:0',		'1::ffff:ffff',		'1::fffff:ffff',		'ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff'	}) do		local success, ip = pcall(IPAddress.new, ipstr) table.insert(results,				'*"' .. ipstr .. '" is ' ..				(success and (ip:isIPv4 and 'IPv4' or 'IPv6') or 'invalid')			) end return table.concat(results, '\n') end

return { main = main }