Skip to content

Commit

Permalink
airflow: Remove ? when none of the query param values are set
Browse files Browse the repository at this point in the history
  • Loading branch information
ish-hcc committed Nov 13, 2024
1 parent a374505 commit 3d5fe6d
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions lib/airflow/gusty.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,23 @@ func parseEndpoint(pathParams map[string]string, queryParams map[string]string,

queryParamKeys := reflect.ValueOf(pathParams).MapKeys()
if len(queryParamKeys) > 0 {
if !strings.Contains(endpoint, "?") {
endpoint += "?"
}
var queryParamsString string

for _, key := range queryParamKeys {
if queryParams[key.String()] == "" {
continue
}
endpoint += fmt.Sprintf("%v=%v&", key.String(), queryParams[key.String()])
queryParamsString += fmt.Sprintf("%v=%v&", key.String(), queryParams[key.String()])
}

if queryParamsString != "" {
queryParamsString = strings.TrimRight(queryParamsString, "&")

if !strings.HasSuffix(endpoint, "?") {
endpoint += "?"
}
endpoint += queryParamsString
}
endpoint = strings.TrimRight(endpoint, "&")
}

return endpoint, nil
Expand Down

0 comments on commit 3d5fe6d

Please sign in to comment.