diff --git a/SessionMessagingKit/Open Groups/OpenGroupAPI.swift b/SessionMessagingKit/Open Groups/OpenGroupAPI.swift index b00f3a7e3..bcef9def5 100644 --- a/SessionMessagingKit/Open Groups/OpenGroupAPI.swift +++ b/SessionMessagingKit/Open Groups/OpenGroupAPI.swift @@ -675,6 +675,8 @@ public enum OpenGroupAPI { on server: String, using dependencies: SMKDependencies = SMKDependencies() ) -> Promise { + /// URL(String:) won't convert raw emojis, so need to do a little encoding here. + /// The raw emoji will come back when calling url.path guard let encodedEmoji: String = emoji.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) else { return Promise(error: OpenGroupAPIError.invalidEmoji) } @@ -700,6 +702,8 @@ public enum OpenGroupAPI { on server: String, using dependencies: SMKDependencies = SMKDependencies() ) -> Promise { + /// URL(String:) won't convert raw emojis, so need to do a little encoding here. + /// The raw emoji will come back when calling url.path guard let encodedEmoji: String = emoji.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) else { return Promise(error: OpenGroupAPIError.invalidEmoji) } @@ -725,6 +729,8 @@ public enum OpenGroupAPI { on server: String, using dependencies: SMKDependencies = SMKDependencies() ) -> Promise { + /// URL(String:) won't convert raw emojis, so need to do a little encoding here. + /// The raw emoji will come back when calling url.path guard let encodedEmoji: String = emoji.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) else { return Promise(error: OpenGroupAPIError.invalidEmoji) } @@ -750,6 +756,8 @@ public enum OpenGroupAPI { on server: String, using dependencies: SMKDependencies = SMKDependencies() ) -> Promise { + /// URL(String:) won't convert raw emojis, so need to do a little encoding here. + /// The raw emoji will come back when calling url.path guard let encodedEmoji: String = emoji.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) else { return Promise(error: OpenGroupAPIError.invalidEmoji) } @@ -1331,7 +1339,7 @@ public enum OpenGroupAPI { guard let url: URL = request.url else { return nil } var updatedRequest: URLRequest = request - let path: String = url.path.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? url.path + let path: String = url.path .appending(url.query.map { value in "?\(value)" }) let method: String = (request.httpMethod ?? "GET") let timestamp: Int = Int(floor(dependencies.date.timeIntervalSince1970)) diff --git a/SessionSnodeKit/OnionRequestAPI.swift b/SessionSnodeKit/OnionRequestAPI.swift index 084081df9..222027bd3 100644 --- a/SessionSnodeKit/OnionRequestAPI.swift +++ b/SessionSnodeKit/OnionRequestAPI.swift @@ -588,7 +588,7 @@ public enum OnionRequestAPI: OnionRequestAPIType { case .v4: // Note: We need to remove the leading forward slash unless we are explicitly hitting a legacy // endpoint (in which case we need it to ensure the request signing works correctly - let endpoint: String = (url.path.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? url.path) + let endpoint: String = url.path .appending(url.query.map { value in "?\(value)" }) let requestInfo: RequestInfo = RequestInfo(