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 17:
Zeile 17:
+
Zeile 58:
Zeile 59:
− +
− +
− +
− host = mw.ustring.match( "." .. host, "%.(" .. pattern ) +
− +
− return host +
+
+
− +
Zeile 75:
Zeile 78:
+
− +
− +
+
− +
− +
Zeile 89:
Zeile 94:
− return ( host .. ":" .. port ) +
− return host +
+
+
− +
Zeile 104:
Zeile 111:
− +
+
− +
Zeile 133:
Zeile 141:
− +
− +
− return mw.ustring.match( auth, "^([%w%.%%-]+):?[%d]*$" ) +
− +
Zeile 149:
Zeile 157:
− +
+
+
Zeile 290:
Zeile 300:
− +
+
Zeile 310:
Zeile 321:
− +
− +
− host = mw.ustring.match( host, "[%w]+%.([a-z][a-z]+)$" ) +
− return host or false +
+
+
− +
Zeile 333:
Zeile 346:
+
− +
+
− return false +
− return false +
− return URLutil.isHost( host ) +
+
+
− +
Zeile 351:
Zeile 368:
+
− s = mw.ustring.match( s, "^%s*([%w%.%%-]+%w)%.[a-zA-Z][a-zA-Z]+%s*$" ) +
+
+
− return false +
− return true +
+
+
− +
Zeile 384:
Zeile 406:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Zeile 444:
Zeile 486:
+
− return legal( p1 ) and legal( p2 ) and legal( p3 ) and legal( p4 ) +
− +
Zeile 693:
Zeile 736:
+
+
+
updates
--[=[ URLutil 2014-09-08
--[=[ URLutil 2014-09-20
Utilities for URL etc. on www.
Utilities for URL etc. on www.
* getAuthority()
* getAuthority()
* isDomain()
* isDomain()
* isDomainExample()
* isDomainExample()
* isDomainInt()
* isHost()
* isHost()
* isIP()
* isIP()
local getTopDomain = function ( url, mode )
local getTopDomain = function ( url, mode )
local host = URLutil.getHost( url )
local r = URLutil.getHost( url )
if host then
if r then
local pattern = "[%w%%]+%.[a-z][a-z]+)$"
local pattern = "[%w%%]+%.%a[%w-]*%a)$"
if mode == 3 then
if mode == 3 then
pattern = "[%w%%]+%." .. pattern
pattern = "[%w%%]+%." .. pattern
end
end
r = mw.ustring.match( "." .. r, "%.(" .. pattern )
if host then
if not r then
r = false
end
end
else
r = false
end
end
return false
return r
end -- getTopDomain()
end -- getTopDomain()
URLutil.getAuthority = function ( url )
URLutil.getAuthority = function ( url )
local r
if type( url ) == "string" then
if type( url ) == "string" then
local s, host, colon, port
local colon, host, port
local pattern = "^%s*%w*:?//([%w%.%%-]+)(:?)([%d]*)/"
local pattern = "^%s*%w*:?//([%w%.%%-]+)(:?)([%d]*)/"
local i = url:find( "#", 6, true )
local s = mw.text.decode( url )
local i = s:find( "#", 6, true )
if i then
if i then
s = url:sub( 1, i - 1 ) .. "/"
s = s:sub( 1, i - 1 ) .. "/"
else
else
s = url .. "/"
s = s .. "/"
end
end
host, colon, port = mw.ustring.match( s, pattern )
host, colon, port = mw.ustring.match( s, pattern )
if colon == ":" then
if colon == ":" then
if port:find( "^[1-9]" ) then
if port:find( "^[1-9]" ) then
r = ( host .. ":" .. port )
end
end
elseif #port == 0 then
elseif #port == 0 then
r = host
end
end
end
end
else
r = false
end
end
return false
return r
end -- URLutil.getAuthority()
end -- URLutil.getAuthority()
local r
local r
if type( url ) == "string" then
if type( url ) == "string" then
local i = url:find( "#", 1, true )
local s = mw.text.decode( url )
local i = s:find( "#", 1, true )
if i then
if i then
r = mw.text.trim( url:sub( i ) ):sub( 2 )
r = mw.text.trim( s:sub( i ) ):sub( 2 )
if type( decode ) == "string" then
if type( decode ) == "string" then
local encoding = mw.text.trim( decode )
local encoding = mw.text.trim( decode )
URLutil.getHost = function ( url )
URLutil.getHost = function ( url )
local auth = URLutil.getAuthority( url )
local r = URLutil.getAuthority( url )
if auth then
if r then
r = mw.ustring.match( r, "^([%w%.%%-]+):?[%d]*$" )
end
end
return false
return r
end -- URLutil.getHost()
end -- URLutil.getHost()
r = false
r = false
else
else
local i = r:find( "#", 1, true )
local i
r = mw.text.decode( r )
i = r:find( "#", 1, true )
if i then
if i then
if i == 1 then
if i == 1 then
local r
local r
if type( url ) == "string" then
if type( url ) == "string" then
local prot, colon, slashes = url:match( "^%s*([a-zA-Z]*)(:?)(//)" )
local pattern = "^%s*([a-zA-Z]*)(:?)(//)"
local prot, colon, slashes = url:match( pattern )
r = false
r = false
if slashes == "//" then
if slashes == "//" then
URLutil.getTLD = function ( url )
URLutil.getTLD = function ( url )
local host = URLutil.getHost( url )
local r = URLutil.getHost( url )
if host then
if r then
r = mw.ustring.match( r, "[%w]+%.(%a[%w-]*%a)$" )
if not r then
r = false
end
end
end
return false
return r
end -- URLutil.getTLD()
end -- URLutil.getTLD()
URLutil.isAuthority = function ( s )
URLutil.isAuthority = function ( s )
local r
if type( s ) == "string" then
if type( s ) == "string" then
local host, colon, port = mw.ustring.match( s, "^%s*([%w%.%%-]+)(:?)(%d*)%s*$" )
local pattern = "^%s*([%w%.%%-]+)(:?)(%d*)%s*$"
local host, colon, port = mw.ustring.match( s, pattern )
if colon == ":" then
if colon == ":" then
port = port:match( "^[1-9][0-9]*$" )
port = port:match( "^[1-9][0-9]*$" )
if type( port ) ~= "string" then
if type( port ) ~= "string" then
r = false
end
end
elseif port ~= "" then
elseif port ~= "" then
r = false
end
end
r = URLutil.isHost( host )
else
r = nil
end
end
return false
return r
end -- URLutil.isAuthority()
end -- URLutil.isAuthority()
URLutil.isDomain = function ( s )
URLutil.isDomain = function ( s )
local r
if type( s ) == "string" then
if type( s ) == "string" then
local scan = "^%s*([%w%.%%-]+%w)%.(%a[%w-]*%a)%s*$"
local scope
s, scope = mw.ustring.match( s, scan )
if type( s ) == "string" then
if type( s ) == "string" then
if mw.ustring.find( s, "^%w" ) then
if mw.ustring.find( s, "^%w" ) then
if mw.ustring.find( s, "..", 1, true ) then
if mw.ustring.find( s, "..", 1, true ) then
r = false
else
else
r = true
end
end
end
end
end
end
else
r = nil
end
end
return false
return r
end -- URLutil.isDomain()
end -- URLutil.isDomain()
return r
return r
end -- URLutil.isDomainExample()
end -- URLutil.isDomainExample()
URLutil.isDomainInt = function ( url )
-- Internationalized Domain Name (Punycode)
local r = URLutil.getHost( url )
if r then
if r:match( "^[!-~]+$" ) then
local s = "." .. r
if s:find( ".xn--", 1, true ) then
r = true
else
r = false
end
else
r = true
end
end
return r
end -- URLutil.isDomainInt()
return ( tonumber( n ) < 256 )
return ( tonumber( n ) < 256 )
end
end
local r = false
if type( s ) == "string" then
if type( s ) == "string" then
local p1, p2, p3, p4 = s:match( "^%s*([1-9][0-9]?[0-9]?)%.([12]?[0-9]?[0-9])%.([12]?[0-9]?[0-9])%.([12]?[0-9]?[0-9])%s*$" )
local p1, p2, p3, p4 = s:match( "^%s*([1-9][0-9]?[0-9]?)%.([12]?[0-9]?[0-9])%.([12]?[0-9]?[0-9])%.([12]?[0-9]?[0-9])%s*$" )
if p1 and p2 and p3 and p4 then
if p1 and p2 and p3 and p4 then
r = legal( p1 ) and legal( p2 ) and legal( p3 ) and legal( p4 )
end
end
end
end
return false
return r
end -- URLutil.isIPv4()
end -- URLutil.isIPv4()
function p.isDomainExample( frame )
function p.isDomainExample( frame )
return URLutil.isDomainExample( frame.args[ 1 ] ) and "1" or ""
return URLutil.isDomainExample( frame.args[ 1 ] ) and "1" or ""
end
function p.isDomainInt( frame )
return URLutil.isDomainInt( frame.args[ 1 ] ) and "1" or ""
end
end
function p.isHost( frame )
function p.isHost( frame )