From 65d2a98412a4778dd9795fdf4a5f1acea43b9b8a Mon Sep 17 00:00:00 2001 From: Pravinthan Prabagaran Date: Wed, 22 Jan 2025 10:40:19 -0500 Subject: [PATCH] Suggestion --- .../Sources/TophatServer/TophatServer.swift | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/TophatModules/Sources/TophatServer/TophatServer.swift b/TophatModules/Sources/TophatServer/TophatServer.swift index 48b699f..c2d61c9 100644 --- a/TophatModules/Sources/TophatServer/TophatServer.swift +++ b/TophatModules/Sources/TophatServer/TophatServer.swift @@ -54,17 +54,9 @@ public final class TophatServer { return .internalServerError } - let queryItems = request.queryParams.map { URLQueryItem(name: $0, value: $1) } + let queryItems = request.queryParams.map { URLQueryItem(name: $0, value: $1.removingPercentEncoding) } - guard let baseURL = baseURL else { - return .internalServerError - } - - let encodedURL = baseURL.appending(path: request.path).appending(queryItems: queryItems) - guard let decodedString = encodedURL.absoluteString.removingPercentEncoding else { - return .internalServerError - } - guard let url = URL(string: decodedString) else { + guard let url = baseURL?.appending(path: request.path).appending(queryItems: queryItems) else { return .internalServerError }