Skip to content

Commit

Permalink
fix(request_information): fix empty string
Browse files Browse the repository at this point in the history
fix empty string
  • Loading branch information
XdpCs committed Jan 16, 2024
1 parent f119d9a commit 728b6d0
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 13 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

## [1.5.4] - 2024-01-16

### Changed

- Fix bug where empty string query parameters are added to the request. [#133](https://github.com/microsoft/kiota-abstractions-go/issues/133)

## [1.5.3] - 2023-11-24

### Added
Expand Down
2 changes: 1 addition & 1 deletion request_information.go
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ func (request *RequestInformation) AddQueryParameters(source any) {
continue
}
str, ok := value.(*string)
if ok && str != nil && *str != "" {
if ok && str != nil {
request.QueryParameters[fieldName] = *str
}
bl, ok := value.(*bool)
Expand Down
12 changes: 0 additions & 12 deletions request_information_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,18 +141,6 @@ func TestItDoesNotSetEmptySelectQueryParameters(t *testing.T) {
assert.Equal(t, "http://localhost/me", resultUri.String())
}

func TestItDoesNotSetEmptySearchQueryParameters(t *testing.T) {
emptyString := ""
requestInformation := NewRequestInformation()
requestInformation.UrlTemplate = "http://localhost/me{?%24search}"
requestInformation.AddQueryParameters(getQueryParameters{
Search: &emptyString,
})
resultUri, err := requestInformation.GetUri()
assert.Nil(t, err)
assert.Equal(t, "http://localhost/me", resultUri.String())
}

func TestItSetsPathParametersOfDateTimeOffsetType(t *testing.T) {
requestInformation := NewRequestInformation()
requestInformation.UrlTemplate = "http://localhost/getDirectRoutingCalls(fromDateTime='{fromDateTime}',toDateTime='{toDateTime}')"
Expand Down

0 comments on commit 728b6d0

Please sign in to comment.