Skip to content

Commit dbccbb5

Browse files
committed
Fix APIEndpoint path
1 parent 24d92e4 commit dbccbb5

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

Sources/PhantomKitAPI/API/APIEndpoint.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public protocol APIEndpoint {
3636

3737
extension APIEndpoint {
3838
public func urlRequest() throws -> URLRequest {
39-
guard let url = URL(string: baseURL)?.appending(component: path) else {
39+
guard let url = URL(string: baseURL)?.appending(path: path) else {
4040
throw APIError.invalidURL
4141
}
4242
return try URLRequest(url: url).applying {

Tests/PhantomKitAPITests/APIEndpoint+Tests.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,18 @@ extension APIEndpointTests {
4646
XCTAssertEqual(request.httpBody, .test)
4747
}
4848

49+
func test_urlRequest_longPath() throws {
50+
let endpoint: APIEndpoint = TestAPIEndpoint(
51+
baseURL: "https://api.example.com",
52+
path: "/test/a/s/v",
53+
method: .get
54+
)
55+
56+
let request = try endpoint.urlRequest()
57+
58+
XCTAssertEqual(request.url?.absoluteString, "https://api.example.com/test/a/s/v")
59+
}
60+
4961
func test_urlRequest_invalidURL() throws {
5062
let endpoint: APIEndpoint = TestAPIEndpoint(
5163
baseURL: "$xyz://api.example.com",

0 commit comments

Comments
 (0)