feat: fixed parsing several filter arguments with quotes (#98)

This commit is contained in:
Ilya Puchka
2017-04-18 23:58:42 +02:00
committed by Kyle Fuller
parent d1717df6ff
commit 5541eae818
2 changed files with 26 additions and 6 deletions

View File

@@ -7,14 +7,18 @@ extension String {
var word = ""
var components: [String] = []
var separate: Character = separator
var singleQuoteCount = 0
var doubleQuoteCount = 0
for character in self.characters {
if character == "'" { singleQuoteCount += 1 }
else if character == "\"" { doubleQuoteCount += 1 }
if character == separate {
if separate != separator {
word.append(separate)
}
if !word.isEmpty {
} else if singleQuoteCount % 2 == 0 && doubleQuoteCount % 2 == 0 && !word.isEmpty {
components.append(word)
word = ""
}