Modul:UrlCheck: Unterschied zwischen den Versionen
+ Funktion uriEncodePath()
K (+ 7C) |
(+ Funktion uriEncodePath()) |
||
| Zeile 2: | Zeile 2: | ||
local UrlCheck = { | local UrlCheck = { | ||
suite = 'vCard', | suite = 'vCard', | ||
serial = '2020-03- | serial = '2020-03-29', | ||
item = 40849609 | item = 40849609 | ||
} | } | ||
| Zeile 25: | Zeile 25: | ||
end | end | ||
function uc.isUrl( url ) | function uc.isUrl( url, skipPathCheck ) | ||
-- return codes 0 through 2 reserved | -- return codes 0 through 2 reserved | ||
if not url or type( url ) ~= 'string' then | if not url or type( url ) ~= 'string' then | ||
| Zeile 69: | Zeile 69: | ||
-- path check | -- path check | ||
if aPath ~= '' and | if not skipPathCheck and aPath ~= '' and | ||
not mw.ustring.match( aPath, '^[-A-Za-z0-9¡-ÿ_.,~%%%|+&:;#*?!=()@/]*$' ) then | not mw.ustring.match( aPath, '^[-A-Za-z0-9¡-ÿ_.,~%%%|+&:;#*?!=()@/]*$' ) then | ||
return 23 | return 23 | ||
| Zeile 152: | Zeile 152: | ||
return 0 | return 0 | ||
end | |||
function uc.uriEncodePath( url ) | |||
local domain, aPath | |||
local at,_ = url:find( '[^/]/[^/]' ) | |||
if at then | |||
domain = url:sub( 1, at + 1 ) | |||
aPath = url:sub( at + 2, #url ) | |||
aPath = mw.uri.encode( aPath, 'PATH' ) | |||
url = domain .. aPath | |||
end | |||
return url | |||
end | end | ||
| Zeile 159: | Zeile 171: | ||
args.show = args.show or '' | args.show = args.show or '' | ||
local result = uc.isUrl( args.url ) | local result = uc.isUrl( args.url, false ) | ||
if args.show:lower() == 'msg' then | if args.show:lower() == 'msg' then | ||
if ui[ result ] then | if ui[ result ] then | ||