Skip to content

Commit 3eb0da6

Browse files
committed
Refactor url.host
1 parent d83a14f commit 3eb0da6

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

Sources/Basics/AuthorizationProvider.swift

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,15 @@ extension AuthorizationProvider {
4343
}
4444
}
4545

46+
extension Foundation.URL {
47+
var authenticationID: String? {
48+
guard let host = host?.lowercased() else {
49+
return nil
50+
}
51+
return host.isEmpty ? nil : host
52+
}
53+
}
54+
4655
// MARK: - netrc
4756

4857
public struct NetrcAuthorizationProvider: AuthorizationProvider {
@@ -103,7 +112,7 @@ public struct NetrcAuthorizationProvider: AuthorizationProvider {
103112
}
104113

105114
private func machineName(for url: Foundation.URL) -> String? {
106-
url.host?.lowercased()
115+
url.authenticationID
107116
}
108117

109118
private func machine(for url: Foundation.URL) -> TSCUtility.Netrc.Machine? {
@@ -248,7 +257,7 @@ public struct KeychainAuthorizationProvider: AuthorizationProvider {
248257
}
249258

250259
private func server(for url: Foundation.URL) -> String? {
251-
url.host?.lowercased()
260+
url.authenticationID
252261
}
253262

254263
private func `protocol`(for url: Foundation.URL) -> CFString {

0 commit comments

Comments
 (0)