Skip to content

Commit

Permalink
fix a bug that couldn't parse paths ending with /
Browse files Browse the repository at this point in the history
  • Loading branch information
yechentide committed Mar 1, 2024
1 parent a2d585e commit d13764c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions utils/string.lua
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ end
function string.getLastComponentFromPath(path)
assert(type(path) == "string")

local i = path:match(".+()/")
if i then
return path:sub(i + 1)
local components = {}
for component in path:gmatch("[^/]+") do
table.insert(components, component)
end
return path
return components[#components]
end

---remove prefix string
Expand Down

0 comments on commit d13764c

Please sign in to comment.