Skip to content

Commit

Permalink
fix: invalid url detection not working correctly (#7016)
Browse files Browse the repository at this point in the history
  • Loading branch information
klesh authored and action_bot committed Feb 26, 2024
1 parent 4eff8ea commit 35fb922
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions backend/plugins/jira/api/connection_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,22 +54,22 @@ func testConnection(ctx context.Context, connection models.JiraConn) (*JiraTestC
// serverInfo checking
res, err := apiClient.Get("api/2/serverInfo", nil, nil)
if err != nil {
// check if `/rest/` was missing
if strings.Contains(err.Error(), "status code 404") && !strings.HasSuffix(connection.Endpoint, "/rest/") {
endpointUrl, err := url.Parse(connection.Endpoint)
if err != nil {
return nil, errors.Convert(err)
}
refUrl, err := url.Parse("/rest/")
if err != nil {
return nil, errors.Convert(err)
}
restUrl := endpointUrl.ResolveReference(refUrl)
return nil, errors.NotFound.New(fmt.Sprintf("Seems like an invalid Endpoint URL, please try %s", restUrl.String()))
}
return nil, err
}
serverInfoFail := "Failed testing the serverInfo: [ " + res.Request.URL.String() + " ]"
// check if `/rest/` was missing
if res.StatusCode == http.StatusNotFound && !strings.HasSuffix(connection.Endpoint, "/rest/") {
endpointUrl, err := url.Parse(connection.Endpoint)
if err != nil {
return nil, errors.Convert(err)
}
refUrl, err := url.Parse("/rest/")
if err != nil {
return nil, errors.Convert(err)
}
restUrl := endpointUrl.ResolveReference(refUrl)
return nil, errors.NotFound.New(fmt.Sprintf("Seems like an invalid Endpoint URL, please try %s", restUrl.String()))
}
if res.StatusCode == http.StatusUnauthorized {
return nil, errors.HttpStatus(http.StatusBadRequest).New("Error username/password")
}
Expand Down

0 comments on commit 35fb922

Please sign in to comment.