Modul:URLutil: Unterschied zwischen den Versionen
update
w>PerfektesChaos (Mehr Funktionen) |
w>PerfektesChaos (update) |
||
Zeile 1: | Zeile 1: | ||
--[=[ URLutil 2013-04- | --[=[ URLutil 2013-04-18 | ||
Utilities for URL etc. on www. | Utilities for URL etc. on www. | ||
* getAuthority() | * getAuthority() | ||
Zeile 13: | Zeile 13: | ||
* isMailAddress() | * isMailAddress() | ||
* isMailLink() | * isMailLink() | ||
* isProtocolDialog | |||
* isProtocolWiki | * isProtocolWiki | ||
* isRessourceURL() | * isRessourceURL() | ||
Zeile 207: | Zeile 208: | ||
function | local function isProtocolAccepted( prot, supplied ) | ||
if type( prot ) == "string" then | if type( prot ) == "string" then | ||
local scheme, colon, slashes = mw.ustring.match( prot, "^%s*([a-zA-Z]*)(:?)(/?/?)%s*$" ) | local scheme, colon, slashes = mw.ustring.match( prot, "^%s*([a-zA-Z]*)(:?)(/?/?)%s*$" ) | ||
Zeile 227: | Zeile 217: | ||
end | end | ||
elseif colon == ":" or slashes == "" then | elseif colon == ":" or slashes == "" then | ||
local s = | local s = supplied:match( " " .. scheme:lower() .. " " ) | ||
if type( s ) == "string" then | if type( s ) == "string" then | ||
return true | |||
end | end | ||
end | end | ||
Zeile 236: | Zeile 225: | ||
end | end | ||
return false | return false | ||
end -- isProtocolAccepted() | |||
function _isProtocolDialog( prot ) | |||
return isProtocolAccepted( prot, " mailto irc ircs telnet " ) | |||
end -- _isProtocolDialog() | |||
function _isProtocolWiki( prot ) | |||
return isProtocolAccepted( prot, | |||
" ftp git http https nntp svn worldwind " ) | |||
end -- _isProtocolWiki() | end -- _isProtocolWiki() | ||
Zeile 342: | Zeile 344: | ||
return _isMailLink( frame.args[ 1 ] ) and "1" or "" | return _isMailLink( frame.args[ 1 ] ) and "1" or "" | ||
end | end | ||
function p. | function p.isProtocolDialog( frame ) | ||
return | return _isProtocolDialog( frame.args[ 1 ] ) and "1" or "" | ||
end | end | ||
function p.isProtocolWiki( frame ) | function p.isProtocolWiki( frame ) |