mirror of
https://github.com/swift-server/swift-openapi-async-http-client.git
synced 2026-05-03 07:42:29 +00:00
Fix double encoding of path parameters (#15)
Fix double encoding of path parameters ### Motivation Fixes https://github.com/apple/swift-openapi-generator/issues/251. ### Modifications Use the already escaped path setter on `URLComponents` to avoid the second encoding pass. ### Result Path parameters that needed escaping are only escaped once, not twice. ### Test Plan Adapted the existing unit test to cover a path item that needs escaping. Reviewed by: simonjbeaumont Builds: ✔︎ pull request validation (5.8) - Build finished. ✔︎ pull request validation (5.9) - Build finished. ✔︎ pull request validation (nightly) - Build finished. ✔︎ pull request validation (soundness) - Build finished. https://github.com/swift-server/swift-openapi-async-http-client/pull/15
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user