Skip to content

Commit 388a2ec

Browse files
authored
Merge pull request #38 from crazy-max/url-concat
improve URL joining to prevent malformed cache service URLs
2 parents 9ace7d4 + de5f8c6 commit 388a2ec

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

cache.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ func (c *Cache) doWithRetries(ctx context.Context, r *request) (*http.Response,
545545
}
546546

547547
func (c *Cache) url(p string) string {
548-
return c.URL + "_apis/artifactcache/" + p
548+
return strings.TrimRight(c.URL, "/") + "/_apis/artifactcache/" + p
549549
}
550550

551551
func (c *Cache) AllKeys(ctx context.Context, api *RestAPI, prefix string) (map[string]struct{}, error) {

cache_v2.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"context"
66
"encoding/json"
77
"io"
8+
"strings"
89
"time"
910

1011
"github.com/Azure/azure-sdk-for-go/sdk/azcore"
@@ -204,5 +205,5 @@ func (c *Cache) newRequestV2(url string, body func() io.Reader) *request {
204205
}
205206

206207
func (c *Cache) urlV2(p string) string {
207-
return c.URL + "twirp/github.actions.results.api.v1.CacheService/" + p
208+
return strings.TrimRight(c.URL, "/") + "/twirp/github.actions.results.api.v1.CacheService/" + p
208209
}

0 commit comments

Comments
 (0)