Module:TrimID
From Ross Surname Project
More actions
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