Modul:URLutil: Unterschied zwischen den Versionen
+getURIScheme (Funktion um URI Schema aus beliebigen URLs auszulesen, also z.B. auch mailto:a@b.de Links)
w>Patrick87 (Füge Funktion "isProtocolMW()" hinzu (alle Protokolle die grundsätzlich vom MediaWiki erkannt werden)) |
w>Patrick87 (+getURIScheme (Funktion um URI Schema aus beliebigen URLs auszulesen, also z.B. auch mailto:a@b.de Links)) |
||
| Zeile 1: | Zeile 1: | ||
--[=[ URLutil 2013- | --[=[ URLutil 2013-08-09 | ||
Utilities for URL etc. on www. | Utilities for URL etc. on www. | ||
* getURIScheme() | |||
* getAuthority() | * getAuthority() | ||
* getHost() | * getHost() | ||
| Zeile 35: | Zeile 36: | ||
-- table for export | -- table for export | ||
local URLutil = {} | local URLutil = {} | ||
URLutil.getURIScheme = function ( uri ) | |||
if type( uri ) == "string" then | |||
local prot, colon, slashes = uri:match( "^%s*([a-zA-Z]*)(:?)(/?/?)" ) | |||
if #colon == 1 and #prot >= 2 then | |||
return prot:lower() | |||
elseif #slashes == 2 and #prot == 0 then | |||
return "//" | |||
end | |||
end | |||
return false | |||
end -- getURIScheme() | |||
| Zeile 430: | Zeile 445: | ||
local p = {} | local p = {} | ||
function p.getURIScheme( frame ) | |||
return URLutil.getURIScheme( frame.args[ 1 ] ) or "" | |||
end | |||
function p.getAuthority( frame ) | function p.getAuthority( frame ) | ||
return URLutil.getAuthority( frame.args[ 1 ] ) or "" | return URLutil.getAuthority( frame.args[ 1 ] ) or "" | ||