Move file-to-lines to String extension
This commit is contained in:
parent
a20512e295
commit
be6abdcf2a
|
@ -191,3 +191,13 @@ extension StringProtocol where Index == String.Index {
|
|||
return NSRange(range, in: self)
|
||||
}
|
||||
}
|
||||
|
||||
extension String {
|
||||
func trimmedLines() -> [String] {
|
||||
return components(separatedBy: .newlines).map {
|
||||
$0.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
}.filter {
|
||||
!$0.isEmpty
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,8 +59,7 @@ extension TunnelKitProvider.Configuration {
|
|||
}
|
||||
|
||||
static func parsed(from url: URL) throws -> (String, TunnelKitProvider.Configuration) {
|
||||
let content = try String(contentsOf: url)
|
||||
let lines = content.components(separatedBy: .newlines).map { $0.trimmingCharacters(in: .whitespacesAndNewlines) }.filter { !$0.isEmpty }
|
||||
let lines = try String(contentsOf: url).trimmedLines()
|
||||
|
||||
var defaultProto: TunnelKitProvider.SocketType?
|
||||
var defaultPort: UInt16?
|
||||
|
|
Loading…
Reference in New Issue