Modul:URLutil: Unterschied zwischen den Versionen
kl
w>PerfektesChaos (update) |
w>PerfektesChaos (kl) |
||
Zeile 1: | Zeile 1: | ||
--[=[ URLutil 2013- | --[=[ URLutil 2013-05-06 | ||
Utilities for URL etc. on www. | Utilities for URL etc. on www. | ||
* getAuthority() | * getAuthority() | ||
Zeile 22: | Zeile 22: | ||
Does not support dotted hexadecimal, dotted octal, or single-number formats. | Does not support dotted hexadecimal, dotted octal, or single-number formats. | ||
IPv6 URL (bracketed) not yet implemented; might need Wikintax escaping anyway. | IPv6 URL (bracketed) not yet implemented; might need Wikintax escaping anyway. | ||
]=] | ]=] | ||
Zeile 84: | Zeile 77: | ||
local prot, colon, slashes = url:match( "^%s*([a-zA-Z]*)(:?)(//)" ) | local prot, colon, slashes = url:match( "^%s*([a-zA-Z]*)(:?)(//)" ) | ||
if slashes == "//" then | if slashes == "//" then | ||
if colon == ":" then | |||
if #prot > 2 then | |||
return prot:lower() .. "://" | |||
end | |||
elseif #prot == 0 then | |||
return "//" | |||
end | |||
end | end | ||
end | end | ||
Zeile 188: | Zeile 181: | ||
URLutil.isMailAddress = function ( s ) | URLutil.isMailAddress = function ( s ) | ||
if type( s ) == "string" then | if type( s ) == "string" then | ||
s = mw.ustring.match( s, "^%s*[%w%.%%_-]+@([%w%.%%-]+)%s*$" ) | |||
return URLutil.isDomain( s ) | |||
end | end | ||
return false | return false | ||
Zeile 198: | Zeile 191: | ||
URLutil.isMailLink = function ( s ) | URLutil.isMailLink = function ( s ) | ||
if type( s ) == "string" then | if type( s ) == "string" then | ||
local addr | |||
s, addr = mw.ustring.match( s, "^%s([Mm][Aa][Ii][Ll][Tt][Oo]):(%S[%w%.%%_-]*@[%w%.%%-]+)%s$*" ) | |||
if type( s ) == "string" then | |||
if s:lower() == "mailto" then | |||
return URLutil.isMailAddress( addr ) | |||
end | |||
end | |||
end | end | ||
return false | return false |