Module:URL to diff
Appearance
This module implements {{URL to diff}}. Please see the template page for documentation.
-- This module converts Wikipedia diff URLs to the {{diff}} template format.
local p = {}
local validDiffValues = {
cur = true,
prev = true,
['next'] = true
}
local function isValidId(s)
local id = tonumber(s)
return id and id > 0
end
local function isValidDiffParam(s)
return s and (validDiffValues[s] or isValidId(s))
end
local function decodeUrl(url)
if type(url) ~= 'string' then
return nil
end
url = mw.uri.new(url)
if not url or url.host ~= 'en.wikipedia.org' or not isValidDiffParam(url.query.diff) then
return nil
end
local data = {}
mw.logObject(data)
end
local function encodeDiffTemplate(data)
end
function p._url(args)
local url = args[1]
local data = decodeUrl(url)
if data then
return encodeDiffTemplate(data)
else
return nil
end
end
function p.url(frame)
local args = require('Module:Arguments').getArgs(frame, {
wrappers = 'Template:Make diff',
})
return p._url(args)
end
return p