From c8d79c2a149153eba15fc7729b2349199dff362f Mon Sep 17 00:00:00 2001 From: Nathan Reiner Date: Wed, 22 Apr 2026 19:12:03 +0200 Subject: fix is_parent on . --- src/lib/path.lua | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/lib') diff --git a/src/lib/path.lua b/src/lib/path.lua index 925f017..72ea94d 100644 --- a/src/lib/path.lua +++ b/src/lib/path.lua @@ -9,6 +9,7 @@ function Path:new(p) p = p:gsub("^%./", "") p = p:gsub("/[^/]+/%.%.", "") p = p:gsub("^[^/]+/%.%./", "") + p = p:gsub("^[^/]+/%.%.$", "") local path = { segments = p:split('/'), @@ -34,6 +35,9 @@ function Path:parent() end function Path:__tostring() + if #self.segments == 0 then + return "." + end return (self.is_absolute and "/" or "") .. table.concat(self.segments, "/") end @@ -132,8 +136,11 @@ function Path:is_parent_of(child) end function Path:relative_to_parent(path) - if not path:is_parent_of(self) then + if #path.segments > 0 and not path:is_parent_of(self) then + print('not parent', path, self) return nil + elseif #path.segments == 0 then + return Path:new(tostring(self)) end return Path:new(tostring(self):sub(#tostring(path) + 2)) -- cgit v1.2.3-70-g09d2