Skip to content

Commit

Permalink
Fix unhandled error in actions_artifacts.go (#2460)
Browse files Browse the repository at this point in the history
  • Loading branch information
mo1ein committed Sep 15, 2022
1 parent e2f7379 commit d611561
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
4 changes: 4 additions & 0 deletions github/actions_artifacts.go
Expand Up @@ -121,6 +121,10 @@ func (s *ActionsService) DownloadArtifact(ctx context.Context, owner, repo strin
}

parsedURL, err := url.Parse(resp.Header.Get("Location"))
if err != nil {
return nil, newResponse(resp), err
}

return parsedURL, newResponse(resp), nil
}

Expand Down
17 changes: 17 additions & 0 deletions github/actions_artifacts_test.go
Expand Up @@ -368,6 +368,23 @@ func TestActionsService_DownloadArtifact_StatusMovedPermanently_followRedirects(
}
}

func TestActionsService_DownloadArtifact_invalidLocationHeader(t *testing.T) {
client, mux, _, teardown := setup()
defer teardown()

mux.HandleFunc("/repos/o/r/actions/artifacts/1/zip", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
ctlChar := 0x7f
badURL := "https://google.com" + string(byte(ctlChar))
w.Header().Add("Location", badURL)
w.WriteHeader(http.StatusFound)
})

ctx := context.Background()
_, _, err := client.Actions.DownloadArtifact(ctx, "o", "r", 1, false)
testURLParseError(t, err)
}

func TestActionsService_DeleteArtifact(t *testing.T) {
client, mux, _, teardown := setup()
defer teardown()
Expand Down

0 comments on commit d611561

Please sign in to comment.