Skip to content

Commit

Permalink
1.7.17
Browse files Browse the repository at this point in the history
  • Loading branch information
dankinsoid committed Apr 15, 2024
1 parent 59b12f2 commit 230f7bb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions Sources/SwiftAPIClient/Modifiers/RequestModifiers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -300,20 +300,23 @@ public extension RequestBuilder where Request == HTTPRequestComponents {
if let host = newBaseURL.host(percentEncoded: false) {
$0.urlComponents.host = host
}
$0.prependPath(newBaseURL.path(percentEncoded: false))
let path = newBaseURL.path(percentEncoded: false)
if !path.isEmpty, path != "/" {
$0.prependPath(path)
}
} else {
if let host = newBaseURL.host {
$0.urlComponents.percentEncodedHost = host
}
if !newBaseURL.path.isEmpty {
if !newBaseURL.path.isEmpty, newBaseURL.path != "/" {
$0.prependPath(newBaseURL.path, percentEncoded: true)
}
}
#else
if let host = newBaseURL.host {
$0.urlComponents.percentEncodedHost = host
}
if !newBaseURL.path.isEmpty {
if !newBaseURL.path.isEmpty, newBaseURL.path != "/" {
$0.prependPath(newBaseURL.path, percentEncoded: true)
}
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ final class RequestModifiersTests: XCTestCase {

func testBaseURLSetting() throws {
let modifiedClient = client.query("test", "value").baseURL(URL(string: "http://test.net")!)
try XCTAssertEqual(modifiedClient.request().url?.absoluteString, "http://test.net/?test=value")
try XCTAssertEqual(modifiedClient.request().url?.absoluteString, "http://test.net?test=value")
}

func testRemoveSlashIfNeeded() throws {
Expand Down

0 comments on commit 230f7bb

Please sign in to comment.