Nicht angemeldeter Benutzer - Bearbeiten von Seiten ist nur als angemeldeter Benutzer möglich.
Änderungen
Zur Navigation springen
Zur Suche springen
Zeile 1:
Zeile 1:
− +
Zeile 7:
Zeile 7:
+
+
+
Zeile 31:
Zeile 34:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Zeile 106:
Zeile 126:
− local host = URLutil.getHost( url ) +
− if host then
− host = mw.ustring.match( "." .. host,
− "(%.[%w%%]+%.[a-z][a-z]+)$" )
− if host then
− return mw.ustring.sub( host, 2 )
− end
− end
− return false
+
+
+
+
+
+
Zeile 152:
Zeile 170:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Zeile 164:
Zeile 201:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Zeile 361:
Zeile 439:
+
+
+
Zeile 367:
Zeile 448:
+
+
+
Zeile 373:
Zeile 457:
+
+
+
update
--[=[ URLutil 2013-06-14
--[=[ URLutil 2013-07-10
Utilities for URL etc. on www.
Utilities for URL etc. on www.
* getAuthority()
* getAuthority()
* getTLD()
* getTLD()
* getTop2domain()
* getTop2domain()
* getTop3domain()
* isAuthority()
* isAuthority()
* isDomain()
* isDomain()
* isDomainExample()
* isHost()
* isHost()
* isIP()
* isIP()
* isIPlocal()
* isIPv4()
* isIPv4()
* isIPv6()
* isIPv6()
-- table for export
-- table for export
local URLutil = {}
local URLutil = {}
local getTopDomain = function ( url, mode )
local host = URLutil.getHost( url )
if host then
local pattern = "[%w%%]+%.[a-z][a-z]+)$"
if mode == 3 then
pattern = "[%w%%]+%." .. pattern
end
host = mw.ustring.match( "." .. host, "%.(" .. pattern )
if host then
return host
end
end
return false
end -- getTopDomain()
URLutil.getTop2domain = function ( url )
URLutil.getTop2domain = function ( url )
return getTopDomain( url, 2 )
end -- URLutil.getTop2domain()
end -- URLutil.getTop2domain()
URLutil.getTop3domain = function ( url )
return getTopDomain( url, 3 )
end -- URLutil.getTop3domain()
return false
return false
end -- URLutil.isDomain()
end -- URLutil.isDomain()
URLutil.isDomainExample = function ( url )
-- RFC 2606: example.com example.net example.org example.edu
local r = getTopDomain( url, 2 )
if r then
local s = r:lower():match( "^example%.([a-z][a-z][a-z])$" )
if s then
r = ( s == "com" or
s == "edu" or
s == "net" or
s == "org" )
else
r = false
end
end
return r
end -- URLutil.isDomainExample()
return URLutil.isIPv4( s ) and 4 or URLutil.isIPv6( s ) and 6
return URLutil.isIPv4( s ) and 4 or URLutil.isIPv6( s ) and 6
end -- URLutil.isIP()
end -- URLutil.isIP()
URLutil.isIPlocal = function ( s )
-- IPv4 according to RFC 1918, RFC 1122; even any 0.0.0.0 (RFC 5735)
local r = false
local num = s:match( "^ *([01][0-9]*)%." )
if num then
num = tonumber( num )
if num == 0 then
r = s:match( "^ *0+%.[0-9]+%.[0-9]+%.[0-9]+ *$" )
elseif num == 10 or num == 127 then
-- loopback; private/local host: 127.0.0.1
r = URLutil.isIPv4( s )
elseif num == 169 then
-- 169.254.*.*
elseif num == 172 then
-- 172.(16...31).*.*
num = s:match( "^ *0*172%.([0-9]+)%." )
if num then
num = tonumber( num )
if num >= 16 and num <= 31 then
r = URLutil.isIPv4( s )
end
end
elseif beg == 192 then
-- 192.168.*.*
num = s:match( "^ *0*192%.([0-9]+)%." )
if num then
num = tonumber( num )
if num == 168 then
r = URLutil.isIPv4( s )
end
end
end
end
if r then
r = true
end
return r
end -- URLutil.isIPlocal()
function p.getTop2domain( frame )
function p.getTop2domain( frame )
return URLutil.getTop2domain( frame.args[ 1 ] ) or ""
return URLutil.getTop2domain( frame.args[ 1 ] ) or ""
end
function p.getTop3domain( frame )
return URLutil.getTop3domain( frame.args[ 1 ] ) or ""
end
end
function p.isAuthority( frame )
function p.isAuthority( frame )
function p.isDomain( frame )
function p.isDomain( frame )
return URLutil.isDomain( frame.args[ 1 ] ) and "1" or ""
return URLutil.isDomain( frame.args[ 1 ] ) and "1" or ""
end
function p.isDomainExample( frame )
return URLutil.isDomainExample( frame.args[ 1 ] ) and "1" or ""
end
end
function p.isHost( frame )
function p.isHost( frame )
function p.isIP( frame )
function p.isIP( frame )
return URLutil.isIP( frame.args[ 1 ] ) or ""
return URLutil.isIP( frame.args[ 1 ] ) or ""
end
function p.isIPlocal( frame )
return URLutil.isIPlocal( frame.args[ 1 ] ) and "1" or ""
end
end
function p.isIPv4( frame )
function p.isIPv4( frame )