From 613a9e314320c5c4292ee5829d2b4f5e8724595d Mon Sep 17 00:00:00 2001 From: Lea Anthony Date: Wed, 23 Feb 2022 20:57:05 +1100 Subject: [PATCH] Bugfix: Fix potential nil dereference --- v2/internal/fs/fs.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/v2/internal/fs/fs.go b/v2/internal/fs/fs.go index a67455de..a1273f32 100644 --- a/v2/internal/fs/fs.go +++ b/v2/internal/fs/fs.go @@ -426,7 +426,9 @@ func FindPathToFile(fsys fs.FS, file string) (string, error) { path, _ := filepath.Split(selected) return path, nil } - - path, _ := filepath.Split(indexFiles.AsSlice()[0]) - return path, nil + if indexFiles.Length() > 0 { + path, _ := filepath.Split(indexFiles.AsSlice()[0]) + return path, nil + } + return "", fmt.Errorf("no index.html found") }