diff --git a/Sources/OpenAPIAsyncHTTPClient/AsyncHTTPClientTransport.swift b/Sources/OpenAPIAsyncHTTPClient/AsyncHTTPClientTransport.swift index 1c5c27a..748c093 100644 --- a/Sources/OpenAPIAsyncHTTPClient/AsyncHTTPClientTransport.swift +++ b/Sources/OpenAPIAsyncHTTPClient/AsyncHTTPClientTransport.swift @@ -161,7 +161,7 @@ public struct AsyncHTTPClientTransport: ClientTransport { guard var baseUrlComponents = URLComponents(string: baseURL.absoluteString) else { throw Error.invalidRequestURL(request: request, baseURL: baseURL) } - baseUrlComponents.path += request.path + baseUrlComponents.percentEncodedPath += request.path baseUrlComponents.percentEncodedQuery = request.query guard let url = baseUrlComponents.url else { throw Error.invalidRequestURL(request: request, baseURL: baseURL) diff --git a/Tests/OpenAPIAsyncHTTPClientTests/Test_AsyncHTTPClientTransport.swift b/Tests/OpenAPIAsyncHTTPClientTests/Test_AsyncHTTPClientTransport.swift index f110257..03b732b 100644 --- a/Tests/OpenAPIAsyncHTTPClientTests/Test_AsyncHTTPClientTransport.swift +++ b/Tests/OpenAPIAsyncHTTPClientTests/Test_AsyncHTTPClientTransport.swift @@ -38,7 +38,7 @@ class Test_AsyncHTTPClientTransport: XCTestCase { func testConvertRequest() throws { let request: OpenAPIRuntime.Request = .init( - path: "/hello/Maria", + path: "/hello%20world/Maria", query: "greeting=Howdy", method: .post, headerFields: [ @@ -50,7 +50,7 @@ class Test_AsyncHTTPClientTransport: XCTestCase { request, baseURL: try XCTUnwrap(URL(string: "http://example.com/api/v1")) ) - XCTAssertEqual(httpRequest.url, "http://example.com/api/v1/hello/Maria?greeting=Howdy") + XCTAssertEqual(httpRequest.url, "http://example.com/api/v1/hello%20world/Maria?greeting=Howdy") XCTAssertEqual(httpRequest.method, .POST) XCTAssertEqual( httpRequest.headers,