File tree Expand file tree Collapse file tree 2 files changed +12
-7
lines changed
Expand file tree Collapse file tree 2 files changed +12
-7
lines changed Original file line number Diff line number Diff line change 11import Foundation
22
33extension 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}
Original file line number Diff line number Diff line change @@ -55,9 +55,7 @@ func performLogin(token: String?) async throws {
5555func 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}
You can’t perform that action at this time.
0 commit comments