Config file parsing: Fix bug when there are comments at the end
Signed-off-by: Roopesh Chander <roop@roopc.net>
This commit is contained in:
@@ -54,10 +54,9 @@ extension TunnelConfiguration {
|
||||
}
|
||||
|
||||
trimmedLine = trimmedLine.trimmingCharacters(in: .whitespaces)
|
||||
let lowercasedLine = trimmedLine.lowercased()
|
||||
|
||||
guard !trimmedLine.isEmpty else { continue }
|
||||
let lowercasedLine = line.lowercased()
|
||||
|
||||
if !trimmedLine.isEmpty {
|
||||
if let equalsIndex = line.firstIndex(of: "=") {
|
||||
// Line contains an attribute
|
||||
let keyWithCase = line[..<equalsIndex].trimmingCharacters(in: .whitespaces)
|
||||
@@ -87,6 +86,7 @@ extension TunnelConfiguration {
|
||||
} else if lowercasedLine != "[interface]" && lowercasedLine != "[peer]" {
|
||||
throw ParseError.invalidLine(line)
|
||||
}
|
||||
}
|
||||
|
||||
let isLastLine = lineIndex == lines.count - 1
|
||||
|
||||
|
||||
Reference in New Issue
Block a user