Module:Freeze/same page link

local p = {}

function p.main(frame) return p._main(frame:getParent.args) end

function p._main(args) local page = mw.text.trim(args[1] or '') local pageId = mw.text.trim(args[2] or '') local revTimestamp = mw.text.trim(args[3] or '') local text = args[4] or ''

local title = page ~= '' and mw.title.new(page) or mw.title.getCurrentTitle title.fragment = '' local queryParts = {'action=history'} if pageId ~= '' then table.insert(queryParts, 'curid=' .. pageId) end if revTimestamp ~= '' then table.insert(queryParts, 'offset=' .. revTimestamp) end table.insert(queryParts, 'limit=2')

local url = title:fullUrl(table.concat(queryParts, '&')) return string.format(' [%s %s] ', url, text) end

return p