Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

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