Skip to content

Commit

Permalink
Merge pull request #10 from thefuntasty/fix/empty-query
Browse files Browse the repository at this point in the history
Do not add query when no parameters are present
  • Loading branch information
mkj-is authored Jan 3, 2019
2 parents 3e6ceef + 85f2a2f commit d3a8c3b
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Sources/URL+APIAdapter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ extension URL {
}

func appendingQuery(parameters: [String: String]) -> URL {
guard !parameters.isEmpty else {
return self
}
var components = URLComponents(url: self, resolvingAgainstBaseURL: true)
let oldItems = components?.queryItems ?? []
components?.queryItems = oldItems + parameters.map(URLQueryItem.init)
Expand Down

0 comments on commit d3a8c3b

Please sign in to comment.