Skip to content

Commit

Permalink
fix: use pathjoin to prevent unexpected separator bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
2color committed Oct 1, 2024
1 parent e734e77 commit 838a363
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions routing/http/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"io"
"mime"
"net/http"
"path"
"sort"
"strings"
"time"
Expand Down Expand Up @@ -222,7 +223,7 @@ func (c *Client) FindProviders(ctx context.Context, key cid.Cid) (providers iter
// TODO test measurements
m := newMeasurement("FindProviders")

url := fmt.Sprintf("%s/routing/v1/providers/%s", c.baseURL, key.String())
url := path.Join(c.baseURL, "routing/v1/providers", key.String())
url = filters.AddFiltersToURL(url, c.protocolFilter, c.addrFilter)

req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil)
Expand Down Expand Up @@ -400,7 +401,7 @@ func (c *Client) provideSignedBitswapRecord(ctx context.Context, bswp *types.Wri
func (c *Client) FindPeers(ctx context.Context, pid peer.ID) (peers iter.ResultIter[*types.PeerRecord], err error) {
m := newMeasurement("FindPeers")

url := fmt.Sprintf("%s/routing/v1/peers/%s", c.baseURL, peer.ToCid(pid).String())
url := path.Join(c.baseURL, "routing/v1/peers", peer.ToCid(pid).String())
url = filters.AddFiltersToURL(url, c.protocolFilter, c.addrFilter)

req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil)
Expand Down

0 comments on commit 838a363

Please sign in to comment.