Modul:UrlCheck: Unterschied zwischen den Versionen

code check
(vereinfacht)
(code check)
Zeile 2: Zeile 2:
local UrlCheck = {
local UrlCheck = {
suite  = 'vCard',
suite  = 'vCard',
serial = '2020-04-01',
serial = '2020-05-16',
item  = 40849609
item  = 40849609
}
}
Zeile 13: Zeile 13:


function uc.ip4( address )
function uc.ip4( address )
local parts = { address:match( '(%d+)%.(%d+)%.(%d+)%.(%d+)' ) }, value
local parts = { address:match( '(%d+)%.(%d+)%.(%d+)%.(%d+)' ) }
local value
if #parts == 4 then
if #parts == 4 then
for _, value in pairs( parts ) do
for _, value in pairs( parts ) do
Zeile 31: Zeile 32:
end
end


local s = mw.text.trim( url ), count, i
local s = mw.text.trim( url )
if s == '' then
if s == '' then
return 3
return 3
Zeile 43: Zeile 44:


-- protocol
-- protocol
local count
s, count = s:gsub( '^https?://', '' )
s, count = s:gsub( '^https?://', '' )
if count == 0 then
if count == 0 then
Zeile 51: Zeile 53:
end
end


local user = '', at
local user = ''
local password = ''
local password = ''
local host = ''
local host = ''
Zeile 59: Zeile 61:


-- split path from host
-- split path from host
at = s:find( '/' )
local at = s:find( '/' )
if at then
if at then
aPath = s:sub( at + 1, #s )
aPath = s:sub( at + 1, #s )
Zeile 92: Zeile 94:
end
end


_,count = user:gsub( ':', ':' )
_, count = user:gsub( ':', ':' )
if count > 1 then
if count > 1 then
return 11
return 11
Zeile 156: Zeile 158:


function uc.uriEncodePath( url )
function uc.uriEncodePath( url )
local domain, aPath
local at, _ = url:find( '[^/]/[^/]' )
local at,_ = url:find( '[^/]/[^/]' )
if at then
if at then
domain = url:sub( 1, at + 1 )
local domain = url:sub( 1, at + 1 )
aPath = url:sub( at + 2, #url )
local aPath = url:sub( at + 2, #url )
aPath = mw.uri.encode( aPath, 'PATH' )
url = domain .. mw.uri.encode( aPath, 'PATH' )
url = domain .. aPath
end
end
return url
return url
Zeile 168: Zeile 168:


function uc.checkUrl( frame )
function uc.checkUrl( frame )
local args = frame.args
local args = frame.args
local pArgs = frame:getParent().args
local pArgs = frame:getParent().args
args.url   = args.url or pArgs.url or ''
args.url   = args.url or pArgs.url or ''
args.show = args.show or pArgs.show or ''
args.show   = args.show or pArgs.show or ''


local result = uc.isUrl( args.url, false )
local result = uc.isUrl( args.url, false )
Zeile 185: Zeile 185:


function uc.encodePath( frame )
function uc.encodePath( frame )
local args = frame.args
local args = frame.args
local pArgs = frame:getParent().args
local pArgs = frame:getParent().args
args.url   = args.url or args[ 1 ] or pArgs.url or pArgs[ 1 ] or ''
args.url   = args.url or args[ 1 ] or pArgs.url or pArgs[ 1 ] or ''
return uc.uriEncodePath( args.url )
return uc.uriEncodePath( args.url )
end
end


return uc
return uc
Anonymer Benutzer