contrib/registry/zookeeper: fix invalid searching prefix (#3598)

This commit is contained in:
cruel
2024-05-22 21:12:21 +08:00
committed by GitHub
parent 21c83670d6
commit 1e8f4287af
2 changed files with 2 additions and 2 deletions

View File

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

View File

@ -31,7 +31,7 @@ func (r *Registry) Register(_ context.Context, service gsvc.Service) (gsvc.Servi
r.opts.namespace,
)
}
prefix := strings.TrimPrefix(strings.ReplaceAll(service.GetPrefix(), "/", "-"), "-")
prefix := strings.Trim(strings.ReplaceAll(service.GetPrefix(), "/", "-"), "-")
servicePrefixPath := path.Join(r.opts.namespace, prefix)
if err = r.ensureName(servicePrefixPath, []byte(""), 0); err != nil {
return service, gerror.Wrapf(