From 8ef5a662945eb0549cb9d920a14b2be05935028a Mon Sep 17 00:00:00 2001 From: Nico Clack <16543008+hedgehog125@users.noreply.github.com> Date: Sun, 23 Nov 2025 14:01:27 +0000 Subject: [PATCH] Add test for nested JavaScript file --- routes_test.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/routes_test.go b/routes_test.go index 3339fe0f..b4a1c085 100644 --- a/routes_test.go +++ b/routes_test.go @@ -669,6 +669,22 @@ func TestRouteStaticFSCleansPath(t *testing.T) { assert.Contains(t, w.Body.String(), "This is another simple embedded page.") } +func TestRouteStaticFSNestedJsFile(t *testing.T) { + router := New() + subFS, err := fs.Sub(embeddedFolder, embeddedPath) + require.NoError(t, err) + fs := &OnlyFilesFS{ + FileSystem: http.FS(subFS), + } + router.StaticFS("/", fs) + router.NoRoute(func(c *Context) { + c.String(http.StatusNotFound, "non existent") + }) + + w := PerformRequest(router, http.MethodGet, "/tutorials/making-gin/main.js") + assert.Contains(t, w.Body.String(), "console.log(\"This is a simple embedded JavaScript file.\");") +} + func TestRouterStaticFSFileNotFound(t *testing.T) { router := New()