From 28d66b408b24d509e2afa966bc51827d4e964217 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=83=E5=B7=9D=E7=99=BD=E6=B5=AA?= <1679659@qq.com> Date: Wed, 2 Dec 2026 06:52:27 -0700 Subject: [PATCH] fix(control): normalize executable path case on Windows for PipeName --- internal/control/control.go | 9 +++++++++ internal/control/control_test.go | 17 +++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 internal/control/control_test.go diff --git a/internal/control/control.go b/internal/control/control.go index bcd1f7a..15c3180 100644 --- a/internal/control/control.go +++ b/internal/control/control.go @@ -7,6 +7,8 @@ import ( "encoding/json" "os" "path/filepath" + "runtime" + "strings" ) const MaxFrameBytes = 8 << 20 @@ -31,7 +33,14 @@ func PipeName() string { if err != nil { exe = "reims-go" } + return pipeNameForExecutable(exe) +} + +func pipeNameForExecutable(exe string) string { identity := filepath.Clean(exe) + if runtime.GOOS == "windows" { + identity = strings.ToLower(identity) + } sum := sha256.Sum256([]byte(identity)) userScope := currentUserScope() return `\\.\pipe\reims-go-control-` + hex.EncodeToString(sum[:8]) + "-" + userScope diff --git a/internal/control/control_test.go b/internal/control/control_test.go new file mode 100644 index 0000000..0595737 --- /dev/null +++ b/internal/control/control_test.go @@ -0,0 +1,17 @@ +package control + +import ( + "runtime" + "testing" +) + +func TestPipeNameWindowsCaseInsensitive(t *testing.T) { + if runtime.GOOS != "windows" { + t.Skip("windows-only path normalization test") + } + upper := pipeNameForExecutable(`D:\Build\reims-go\build\bin\reims-go.exe`) + lower := pipeNameForExecutable(`d:\build\reims-go\build\bin\reims-go.exe`) + if upper != lower { + t.Fatalf("expected case-insensitive pipe name on Windows: %q != %q", upper, lower) + } +}