Skip to content

Commit

Permalink
Fix encoding for localhost scheme-based URLS
Browse files Browse the repository at this point in the history
  • Loading branch information
pravinthan committed Jan 22, 2025
1 parent d1c7789 commit 7583df0
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion TophatModules/Sources/TophatServer/TophatServer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,13 @@ public final class TophatServer {

let queryItems = request.queryParams.map { URLQueryItem(name: $0, value: $1) }

guard let url = baseURL?.appending(path: request.path).appending(queryItems: queryItems) else {
guard let baseURL = baseURL else {
return .internalServerError
}

let encodedURL = baseURL.appending(path: request.path).appending(queryItems: queryItems)
guard let decodedString = encodedURL.absoluteString.removingPercentEncoding,
let url = URL(string: decodedString) else {
return .internalServerError
}

Expand Down

0 comments on commit 7583df0

Please sign in to comment.