Modul:URLutil: Unterschied zwischen den Versionen
moved comment about "only dotted decimal ipv4" to module header.
w>Dcoetzee (isIpv4: -- Currently supports only dotted decimal notation for IPv4. Does not support -- dotted hexadecimal, dotted octal, or single-number formats (see IPv4#Address_representations).) |
w>קיפודנחש (moved comment about "only dotted decimal ipv4" to module header.) |
||
| Zeile 1: | Zeile 1: | ||
--[[ | --[=[ | ||
Functions are not "local", so other modules can require this module and call them directly. | Functions are not "local", so other modules can require this module and call them directly. | ||
We return an object with 3 small stub functions to call the real ones so that the functions | We return an object with 3 small stub functions to call the real ones so that the functions | ||
can be called from templates also. | can be called from templates also. | ||
Only [[dotted decimal]] notation for IPv4 supported. Does not support | |||
dotted hexadecimal, dotted octal, or single-number formats (see [[IPv4#Address_representations]]). | |||
Unit tests at Module:IPAddress/tests | Unit tests at Module:IPAddress/tests | ||
]] | ]=] | ||
function _isIpV6( s ) | function _isIpV6( s ) | ||
| Zeile 26: | Zeile 29: | ||
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! | ||