From 2207e4a4a4f4b8d68469d82e2c48f2a212a6b59c Mon Sep 17 00:00:00 2001 From: Alejandro Mery Date: Fri, 25 Aug 2023 16:02:00 +0000 Subject: [PATCH] zones: fix New() to handle relative paths on hackpadfs Signed-off-by: Alejandro Mery --- pkg/zones/zones.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pkg/zones/zones.go b/pkg/zones/zones.go index 817fd97..92489c4 100644 --- a/pkg/zones/zones.go +++ b/pkg/zones/zones.go @@ -3,6 +3,7 @@ package zones import ( "io/fs" + "path/filepath" "github.com/hack-pad/hackpadfs/os" @@ -105,7 +106,12 @@ func NewFS(dir fs.FS, domain string) (*Zones, error) { // New builds a [Zones] tree using the given directory func New(dir, domain string) (*Zones, error) { - base, err := os.NewFS().Sub(dir) + dir, err := filepath.Abs(dir) + if err != nil { + return nil, err + } + + base, err := os.NewFS().Sub(dir[1:]) if err != nil { return nil, err }