Skip to content

Commit 437e90a

Browse files
Merge pull request #2386 from northtyphoon/bindu/acr-push-location
docker/pusher: handle location string containing path and query
2 parents 081b2d6 + 9b865d8 commit 437e90a

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

remotes/docker/pusher.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,18 @@ func (p dockerPusher) Push(ctx context.Context, desc ocispec.Descriptor) (conten
155155
location := resp.Header.Get("Location")
156156
// Support paths without host in location
157157
if strings.HasPrefix(location, "/") {
158-
u := p.base
159-
u.Path = location
160-
location = u.String()
158+
// Support location string containing path and query
159+
qmIndex := strings.Index(location, "?")
160+
if qmIndex > 0 {
161+
u := p.base
162+
u.Path = location[:qmIndex]
163+
u.RawQuery = location[qmIndex+1:]
164+
location = u.String()
165+
} else {
166+
u := p.base
167+
u.Path = location
168+
location = u.String()
169+
}
161170
}
162171

163172
req, err = http.NewRequest(http.MethodPut, location, nil)

0 commit comments

Comments
 (0)