From 695ca1730af2b6023adadbb5c0da86ea496f6cfa Mon Sep 17 00:00:00 2001 From: Jun <16631927+creamtea47@users.noreply.github.com> Date: Tue, 1 Sep 2026 23:44:48 +0800 Subject: [PATCH] fix: encode Windows CWD paths for web routes --- internal/parser/encoding.go | 2 +- internal/parser/encoding_extra_test.go | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/internal/parser/encoding.go b/internal/parser/encoding.go index 63905ef..d759b94 100644 --- a/internal/parser/encoding.go +++ b/internal/parser/encoding.go @@ -21,7 +21,7 @@ func EncodePath(path string) string { if path == "" { return "" } - encoded := strings.ReplaceAll(path, "/", "-") + encoded := strings.NewReplacer("/", "-", "\\", "-").Replace(path) if strings.HasPrefix(encoded, "-") { return encoded[1:] } diff --git a/internal/parser/encoding_extra_test.go b/internal/parser/encoding_extra_test.go index 561eb2d..772102e 100644 --- a/internal/parser/encoding_extra_test.go +++ b/internal/parser/encoding_extra_test.go @@ -99,6 +99,7 @@ func TestEncodePath(t *testing.T) { {"/home/user/app", "home-user-app"}, {"", ""}, {"relative/path", "relative-path"}, + {`C:\Users\jc\Desktop\project`, "C:-Users-jc-Desktop-project"}, } for _, tt := range tests {