Skip to content

Commit a10a518

Browse files
committed
wip
1 parent 02636a9 commit a10a518

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

Sources/pfw/Helpers.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import Foundation
22

33
extension URL {
4-
static var baseURL: String {
4+
static var baseURL: URL {
55
#if DEBUG
6-
return "http://localhost:8080"
6+
return URL(string: "http://localhost:8080")!
77
#else
8-
return "https://www.pointfree.co"
8+
return URL(string: "https://www.pointfree.co")!
99
#endif
1010
}
1111
}

Sources/pfw/Login.swift

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,7 @@ func performLogin(token: String?) async throws {
5555
func makeLoginURL(redirectURL: URL?) throws -> URL {
5656
@Dependency(\.whoAmI) var whoAmI
5757

58-
guard var components = URLComponents(string: URL.baseURL) else {
59-
return URL(string: "https://www.pointfree.co/account/the-way/login")!
60-
}
58+
var components = URLComponents(url: .baseURL, resolvingAgainstBaseURL: false)!
6159
components.path = "/account/the-way/login"
6260
var items = [
6361
URLQueryItem(name: "whoami", value: whoAmI()),
@@ -67,5 +65,12 @@ func makeLoginURL(redirectURL: URL?) throws -> URL {
6765
items.append(URLQueryItem(name: "redirect", value: redirectURL.absoluteString))
6866
}
6967
components.queryItems = items
70-
return components.url ?? URL(string: "https://www.pointfree.co/account/the-way/login")!
68+
guard let url = components.url
69+
else {
70+
struct InvalidRedirectURL: Error {
71+
let components: URLComponents
72+
}
73+
throw InvalidRedirectURL(components: components)
74+
}
75+
return url
7176
}

0 commit comments

Comments
 (0)