         return Netrc.from(fileContents)
     }
     
+    
+    /// Regex matching logic for deriving `Netrc` container from string content
+    /// - Parameter content: String text of netrc file
+    /// - Returns: `Netrc` container with parsed connection settings, or error
     public static func from(_ content: String) -> Result<Netrc, Netrc.Error> {
         
         let content = trimComments(from: content)

import Foundation

@available (OSX 10.13, *)
public struct Netrc {
    
    public struct Machine: Equatable {
        public var isDefault: Bool {
            return name == "default"
        }
        public let name: String
        public let login: String
        public let password: String
        
        init?(for match: NSTextCheckingResult, string: String, variant: String = "") {
            guard let name = Token.machine.capture(in: match, string: string) ?? Token.default.capture(in: match, string: string),
                let login = Token.login.capture(prefix: variant, in: match, string: string),
                let password = Token.password.capture(prefix: variant, in: match, string: string) else {
                    return nil
            }
            self = Machine(name: name, login: login, password: password)
        }
        
        public init(name: String, login: String, password: String) {
            self.name = name
            self.login = login
            self.password = password
        }
    }
    
    public enum Error: Swift.Error {
        case fileNotFound(Foundation.URL)
        case unreadableFile(Foundation.URL)
        case machineNotFound
        case invalidDefaultMachinePosition
    }
    
    @frozen private enum Token: String, CaseIterable {
        case machine
        case login
        case password
        case macdef
        case `default`
        
        func capture(prefix: String = "", in match: NSTextCheckingResult, string: String) -> String? {
            guard let range = Range(match.range(withName: prefix + rawValue), in: string) else { return nil }
            return String(string[range])
        }
    }
    
    public let machines: [Machine]
    
    init(machines: [Machine]) {
        self.machines = machines
    }
    
    public func authorization(for url: Foundation.URL) -> String? {
        guard let index = machines.firstIndex(where: { $0.name == url.host }) ?? machines.firstIndex(where: { $0.isDefault }) else { return nil }
        let machine = machines[index]

        return .success(Netrc(machines: machines))
    }
    
    
    /// Utility method to trim comments from netrc content
    /// - Parameter text: String text of netrc file
    /// - Returns: String text of netrc file *sans* comments
    private static func trimComments(from text: String) -> String {
        let regex = try! NSRegularExpression(pattern: RegexUtil.comments, options: .anchorsMatchLines)
        let nsString = text as NSString
