Module:TrimID: Difference between revisions
From Ross Surname Project
More actions
Redheadkelly (talk | contribs) m Redheadkelly moved page Module:NRS collection reference number to Module:TrimID without leaving a redirect |
Redheadkelly (talk | contribs) m 1 revision imported |
(No difference)
| |
Latest revision as of 19:57, 21 July 2025
Documentation for this module may be created at Module:TrimID/doc
-- Module:TrimID
local p = {}
function p.remove_last_id(frame)
local id = frame.args[1] or ''
if id == '' then return '' end
-- Split by '/'
local parts = mw.text.split(id, '/')
-- Remove last part if there's more than one
if #parts > 1 then
table.remove(parts) -- remove the last element
end
-- Recombine and return
return table.concat(parts, '/')
end
return p