Modul:URLutil: Unterschied zwischen den Versionen
2022-04-05
K (50 Versionen von w:Modul:URLutil importiert) |
(2022-04-05) |
||
Zeile 1: | Zeile 1: | ||
local URLutil = { suite = "URLutil", | local URLutil = { suite = "URLutil", | ||
serial = " | serial = "2022-04-05", | ||
item = 10859193 } | item = 10859193 } | ||
--[=[ | --[=[ | ||
Zeile 128: | Zeile 128: | ||
end | end | ||
n = ( ask:byte( j, j ) - 48 ) * 16 + n | n = ( ask:byte( j, j ) - 48 ) * 16 + n | ||
if decodeComponentEscape( averse, n ) then | if n == 39 and | ||
ask:sub( i + 3, i + 5 ) == "%27" then | |||
j = i + 6 | |||
while ( ask:sub( j, j + 2 ) == "%27" ) do | |||
j = j + 3 | |||
end -- while "%27" | |||
elseif decodeComponentEscape( averse, n ) then | |||
if m then | if m then | ||
ask = string.format( "%s%c%s", | ask = string.format( "%s%c%s", | ||
Zeile 966: | Zeile 972: | ||
-- Retrieve versioning and check for compliance | -- Retrieve versioning and check for compliance | ||
-- Precondition: | -- Precondition: | ||
-- atleast -- string, with required version | -- atleast -- string, with required version | ||
-- | -- or wikidata|item|~|@ or false | ||
-- Postcondition: | -- Postcondition: | ||
-- Returns string -- with queried version, also if problem | -- Returns string -- with queried version/item, also if problem | ||
-- false -- if appropriate | -- false -- if appropriate | ||
-- | -- 2020-08-17 | ||
local since = atleast | local since = atleast | ||
local last = ( since == "~" ) | |||
local linked = ( since == "@" ) | |||
local link = ( since == "item" ) | |||
local r | local r | ||
if last or since == "wikidata" then | if last or link or linked or since == "wikidata" then | ||
local item = Failsafe.item | local item = Failsafe.item | ||
since = false | since = false | ||
if type( item ) == "number" and item > 0 then | if type( item ) == "number" and item > 0 then | ||
local | local suited = string.format( "Q%d", item ) | ||
if link then | |||
r = suited | |||
else | |||
local entity = mw.wikibase.getEntity( suited ) | |||
if type( entity ) == "table" then | |||
local seek = Failsafe.serialProperty or "P348" | |||
local vsn = entity:formatPropertyValues( seek ) | |||
if type( vsn ) == "table" and | |||
r = false | type( vsn.value ) == "string" and | ||
vsn.value ~= "" then | |||
r = vsn.value | if last and vsn.value == Failsafe.serial then | ||
r = false | |||
elseif linked then | |||
if mw.title.getCurrentTitle().prefixedText | |||
== mw.wikibase.getSitelink( suited ) then | |||
r = false | |||
else | |||
r = suited | |||
end | |||
else | |||
r = vsn.value | |||
end | |||
end | end | ||
end | end |