From 3a893d15add661ac14e44e4306868038ffee6375 Mon Sep 17 00:00:00 2001 From: Gani Georgiev Date: Thu, 2 Apr 2026 08:06:11 +0300 Subject: [PATCH] avoid explicit fs.FS wrapping --- plugins/jsvm/binds.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/plugins/jsvm/binds.go b/plugins/jsvm/binds.go index ac00c945..6ec4b9ff 100644 --- a/plugins/jsvm/binds.go +++ b/plugins/jsvm/binds.go @@ -6,6 +6,7 @@ import ( "encoding/json" "errors" "io" + "io/fs" "log/slog" "net/http" "os" @@ -814,8 +815,15 @@ func apisBinds(vm *goja.Runtime) { obj := vm.NewObject() vm.Set("$apis", obj) - obj.Set("static", func(dir string, indexFallback bool) func(*core.RequestEvent) error { - return apis.Static(os.DirFS(dir), indexFallback) + obj.Set("static", func(dirOrFS any, indexFallback bool) func(*core.RequestEvent) error { + switch v := dirOrFS.(type) { + case fs.FS: + return apis.Static(v, indexFallback) + case string: + return apis.Static(os.DirFS(v), indexFallback) + default: + panic("$apis.static expects the first argument to be either a plain string path or fs.FS value") + } }) // middlewares