Skip to content

Commit 8260215

Browse files
committed
tighted up whitespace
1 parent f92b85b commit 8260215

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

Sources/TSCUtility/Netrc.swift

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import Foundation
22
import TSCBasic
3+
34
/// Supplies `Authorization` header, typically to be appended to `URLRequest`
45
public protocol AuthorizationProviding {
56
/// Optional `Authorization` header, likely added to `URLRequest`
@@ -11,6 +12,7 @@ extension AuthorizationProviding {
1112
return nil
1213
}
1314
}
15+
1416
#if os(Windows)
1517
// FIXME: - add support for Windows when regex function available
1618
#endif
@@ -24,11 +26,9 @@ extension AuthorizationProviding {
2426
Netrc feature depends upon `NSTextCheckingResult.range(withName name: String) -> NSRange`,
2527
which is only available in macOS 10.13+ at this time.
2628
*/
27-
2829
@available (OSX 10.13, *)
2930
/// Container of parsed netrc connection settings
3031
public struct Netrc: AuthorizationProviding {
31-
3232
/// Representation of `machine` connection settings & `default` connection settings.
3333
/// If `default` connection settings present, they will be last element.
3434
public let machines: [Machine]
@@ -61,7 +61,6 @@ public struct Netrc: AuthorizationProviding {
6161
return Netrc.from(fileContents)
6262
}
6363

64-
6564
/// Regex matching logic for deriving `Netrc` container from string content
6665
/// - Parameter content: String text of netrc file
6766
/// - Returns: `Netrc` container with parsed connection settings, or error
@@ -100,7 +99,6 @@ public struct Netrc: AuthorizationProviding {
10099

101100
@available (OSX 10.13, *)
102101
public extension Netrc {
103-
104102
enum Error: Swift.Error {
105103
case invalidFilePath
106104
case fileNotFound(AbsolutePath)
@@ -139,9 +137,7 @@ public extension Netrc {
139137

140138
@available (OSX 10.13, *)
141139
fileprivate enum RegexUtil {
142-
143140
@frozen fileprivate enum Token: String, CaseIterable {
144-
145141
case machine, login, password, account, macdef, `default`
146142

147143
func capture(prefix: String = "", in match: NSTextCheckingResult, string: String) -> String? {
@@ -151,15 +147,12 @@ fileprivate enum RegexUtil {
151147
}
152148

153149
static let comments: String = "\\#[\\s\\S]*?.*$"
154-
155150
static let `default`: String = #"(?:\s*(?<default>default))"#
156151
static let accountOptional: String = #"(?:\s*account\s+\S++)?"#
157-
158152
static let loginPassword: String = #"\#(namedTrailingCapture("login", prefix: "lp"))\#(accountOptional)\#(namedTrailingCapture("password", prefix: "lp"))"#
159153
static let passwordLogin: String = #"\#(namedTrailingCapture("password", prefix: "pl"))\#(accountOptional)\#(namedTrailingCapture("login", prefix: "pl"))"#
160-
161154
static let netrcPattern = #"(?:(?:(\#(namedTrailingCapture("machine"))|\#(namedMatch("default"))))(?:\#(loginPassword)|\#(passwordLogin)))"#
162-
155+
163156
static func namedMatch(_ string: String) -> String {
164157
return #"(?:\s*(?<\#(string)>\#(string)))"#
165158
}

0 commit comments

Comments
 (0)