diff --git a/pkg/http/mux.go b/pkg/http/mux.go index 19d1195e..46a76b02 100644 --- a/pkg/http/mux.go +++ b/pkg/http/mux.go @@ -66,7 +66,11 @@ func (m *prefixMuxMap[T]) get(path string) (val T, exist bool) { // match assume pattern like `/core.v1.AuthenticateService/login` func (m *prefixMuxMap[T]) match(pattern string) (val T, exist bool) { - path, _ := strings.CutPrefix(pattern, m.prefix) + path, found := strings.CutPrefix(pattern, m.prefix) + if !found { + exist = false + return + } idx := strings.IndexByte(path[1:], '/') if idx < 0 { return diff --git a/pkg/http/mux_test.go b/pkg/http/mux_test.go index 7069e9da..e67d5f47 100644 --- a/pkg/http/mux_test.go +++ b/pkg/http/mux_test.go @@ -66,5 +66,8 @@ var _ = g.Describe("Mux", g.Ordered, func() { val, exist = pmm.match("/connect/core.v1.AuthenticateService/logout") m.Expect(val).To(m.Equal(1)) m.Expect(exist).To(m.BeTrue()) + + _, exist = pmm.match("/core.v1.AuthenticateService/logout") + m.Expect(exist).To(m.BeFalse()) }) })