Modul:URLutil: Unterschied zwischen den Versionen
update
w>Patrick87 (+getURIScheme (Funktion um URI Schema aus beliebigen URLs auszulesen, also z.B. auch mailto:a@b.de Links)) |
w>PerfektesChaos (update) |
||
| Zeile 1: | Zeile 1: | ||
--[=[ URLutil | --[=[ URLutil 2014-05-01 | ||
Utilities for URL etc. on www. | Utilities for URL etc. on www. | ||
* getURIScheme() | * getURIScheme() | ||
| Zeile 72: | Zeile 72: | ||
URLutil.getAuthority = function ( url ) | URLutil.getAuthority = function ( url ) | ||
if type( url ) == "string" then | if type( url ) == "string" then | ||
local host, colon, port = | local s, host, colon, port | ||
local pattern = "^%s*%w*:?//([%w%.%%-]+)(:?)([%d]*)/" | |||
local i = url:find( "#", 6, true ) | |||
if i then | |||
s = url:sub( 1, i - 1 ) .. "/" | |||
else | |||
s = url .. "/" | |||
end | |||
host, colon, port = mw.ustring.match( s, pattern ) | |||
if URLutil.isHost( host ) then | if URLutil.isHost( host ) then | ||
host = mw.ustring.lower( host ) | host = mw.ustring.lower( host ) | ||