Add support for quotes around colons when searching (#162)

This commit is contained in:
David Dworken
2024-01-07 18:56:30 -08:00
committed by GitHub
parent 12f0aa1bff
commit e86f7bf382
7 changed files with 119 additions and 3 deletions

View File

@ -288,7 +288,7 @@ func TestSplitEscaped(t *testing.T) {
{"'foo bar baz", ' ', -1, []string{"'foo", "bar", "baz"}},
{"'foo bar baz\\''", ' ', -1, []string{"foo bar baz'"}},
{"cwd:'foo bar :baz\\''", ':', -1, []string{"cwd", "foo bar :baz'"}},
{"cwd:'foo bar :baz\\''", ' ', -1, []string{"cwd:foo bar :baz'"}},
{"cwd:'foo bar :baz\\''", ' ', -1, []string{"cwd:foo bar \\:baz'"}},
// Tests for double quotes
{"\"foo bar\"", ' ', -1, []string{"foo bar"}},
{"\"foo bar\" \" \"", ' ', -1, []string{"foo bar", " "}},
@ -296,7 +296,7 @@ func TestSplitEscaped(t *testing.T) {
{"\"foo bar baz", ' ', -1, []string{"\"foo", "bar", "baz"}},
{"\"foo bar baz\\\"\"", ' ', -1, []string{"foo bar baz\""}},
{"cwd:\"foo bar :baz\\\"\"", ':', -1, []string{"cwd", "foo bar :baz\""}},
{"cwd:\"foo bar :baz\\\"\"", ' ', -1, []string{"cwd:foo bar :baz\""}},
{"cwd:\"foo bar :baz\\\"\"", ' ', -1, []string{"cwd:foo bar \\:baz\""}},
// Tests for complex quotes
{"\"foo'bar\"", ' ', -1, []string{"foo'bar"}},
{"'foo\"bar'", ' ', -1, []string{"foo\"bar"}},
@ -318,6 +318,10 @@ func TestSplitEscaped(t *testing.T) {
{"foo:bar", ' ', -1, []string{"foo:bar"}},
{"foo\\:bar", ':', -1, []string{"foo\\:bar"}},
{"foo\\:bar", ' ', -1, []string{"foo\\:bar"}},
// Tests for quoting colons
{"foo:bar", ' ', -1, []string{"foo:bar"}},
{"'foo:bar'", ' ', -1, []string{"foo\\:bar"}},
{"\"foo:bar\"", ' ', -1, []string{"foo\\:bar"}},
}
for _, tc := range testcases {
actual := splitEscaped(tc.input, tc.char, tc.limit)