Modul:WLink: Unterschied zwischen den Versionen
2016-05-18
wp>PerfektesChaos (2015-06-20) |
wp>PerfektesChaos (2016-05-18) |
||
Zeile 1: | Zeile 1: | ||
local WLink = { suite = "WLink", | local WLink = { suite = "WLink", | ||
serial = " | serial = "2016-05-18" }; | ||
--[=[ | --[=[ | ||
ansiPercent() | ansiPercent() | ||
Zeile 759: | Zeile 759: | ||
function WLink.getWeblink( attempt, anURLutil ) | function WLink.getWeblink( attempt, anURLutil ) | ||
-- Retrieve bracketed link from URL | -- Retrieve bracketed link from resource URL | ||
-- Precondition: | -- Precondition: | ||
-- attempt -- string, with URL, or something different | -- attempt -- string, with URL, or something different | ||
Zeile 774: | Zeile 774: | ||
end | end | ||
if URLutil.isResourceURL( attempt ) then | if URLutil.isResourceURL( attempt ) then | ||
local | local site = URLutil.getAuthority( attempt ); | ||
local show; | |||
if #attempt == #site then | |||
site = site .. "/"; | |||
end | |||
show = URLutil.getTop3domain( "//" .. site ); | |||
if show then | if show then | ||
local scan = "[%./](%a+)(%.%l%l%.)(%a+)$"; | |||
local search = "." .. show; | local search = "." .. show; | ||
local s1, s2, s3 = search:match( scan ); | local s1, s2, s3 = search:match( scan ); | ||
Zeile 788: | Zeile 793: | ||
end | end | ||
if not show then | if not show then | ||
show = URLutil.getTop2domain( | show = URLutil.getTop2domain( "//" .. site ); | ||
if not show then | |||
show = URLutil.getHost( "//" .. site ); | |||
end | |||
end | end | ||
r = string.format( "[%s %s]", attempt, show ); | r = string.format( "[%s %s]", attempt, show ); |