Skip to content

Commit 1e8f428

Browse files
authored
contrib/registry/zookeeper: fix invalid searching prefix (#3598)
1 parent 21c8367 commit 1e8f428

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

contrib/registry/zookeeper/zookeeper_discovery.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import (
1919

2020
// Search searches and returns services with specified condition.
2121
func (r *Registry) Search(_ context.Context, in gsvc.SearchInput) ([]gsvc.Service, error) {
22-
prefix := strings.TrimPrefix(strings.ReplaceAll(in.Prefix, "/", "-"), "-")
22+
prefix := strings.Trim(strings.ReplaceAll(in.Prefix, "/", "-"), "-")
2323
instances, err, _ := r.group.Do(prefix, func() (interface{}, error) {
2424
serviceNamePath := path.Join(r.opts.namespace, prefix)
2525
servicesID, _, err := r.conn.Children(serviceNamePath)

contrib/registry/zookeeper/zookeeper_registrar.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func (r *Registry) Register(_ context.Context, service gsvc.Service) (gsvc.Servi
3131
r.opts.namespace,
3232
)
3333
}
34-
prefix := strings.TrimPrefix(strings.ReplaceAll(service.GetPrefix(), "/", "-"), "-")
34+
prefix := strings.Trim(strings.ReplaceAll(service.GetPrefix(), "/", "-"), "-")
3535
servicePrefixPath := path.Join(r.opts.namespace, prefix)
3636
if err = r.ensureName(servicePrefixPath, []byte(""), 0); err != nil {
3737
return service, gerror.Wrapf(

0 commit comments

Comments
 (0)