Skip to content

Commit

Permalink
Merge e2b61fc into 4fc9132
Browse files Browse the repository at this point in the history
  • Loading branch information
paultopher committed Aug 12, 2020
2 parents 4fc9132 + e2b61fc commit af42bd4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions Source/Client.swift
Expand Up @@ -148,6 +148,12 @@ internal final class Client: ClientType {
}
if let appId = applicationId {
parameters["application_id"] = appId.rawValue
let appFormat = String(format: "https://%@.mobileapi", appId.rawValue)
let urlString = urlRequest.url?.absoluteString.replacingOccurrences(of: "https://mobileapi", with: appFormat)
if let urlString = urlString,
let url = URL(string: urlString) {
urlRequest.url = url
}
}
urlRequest.httpBody = try? JSONSerialization.data(withJSONObject: parameters)
enqueueRequest(request: urlRequest, completion: pendingTask.completion)
Expand Down
4 changes: 2 additions & 2 deletions Tests/UnitTests/ClientTests.swift
Expand Up @@ -700,9 +700,9 @@ class ClientTests: XCTestCase {
// Assert
XCTAssertEqual(testURLSession.allDataTasks.count, 2)
XCTAssertEqual(testURLSession.allDataTasks[0].originalRequest?.url?.absoluteString,
"https://mobileapi.usebutton.com/v1/app/deferred-deeplink")
"https://app-test.mobileapi.usebutton.com/v1/app/deferred-deeplink")
XCTAssertEqual(testURLSession.allDataTasks[1].originalRequest?.url?.absoluteString,
"https://mobileapi.usebutton.com/v1/app/events")
"https://app-test.mobileapi.usebutton.com/v1/app/events")
XCTAssertEqual(client.pendingTasks.count, 0)
testURLSession.allDataTasks.forEach { task in
let json = try? JSONSerialization.jsonObject(with: task.originalRequest!.httpBody!) as? NSDictionary
Expand Down

0 comments on commit af42bd4

Please sign in to comment.