fix spaced quotes causing weird behavior in search.
continuous-integration/drone/push Build is passing

This commit is contained in:
2021-03-30 21:16:02 +02:00
parent 18a83073e8
commit 33ac47a12c
2 changed files with 17 additions and 10 deletions
+6
View File
@@ -17,14 +17,19 @@ func TSQueryFromSearch(search string) string {
startQuotes := false
if strings.HasPrefix(token, "\"") {
if len(token) > 1 {
token = token[1:]
}
startQuotes = true
}
if strings.HasSuffix(token, "\"") {
token = token[:len(token)-1]
startQuotes = false
clearQuotes = true
}
token := strings.Trim(token, ",.;:()\"")
if len(token) > 0 {
if startQuotes {
if i > 0 {
result += " & "
@@ -38,6 +43,7 @@ func TSQueryFromSearch(search string) string {
}
result += token
}
if startQuotes {
inQuotes = true
+1
View File
@@ -13,6 +13,7 @@ func TestTSQueryFromSearch(t *testing.T) {
{`"asari matron" blue`, `(asari<->matron) & blue`},
{`"christmas present" "wrapping paper"`, `(christmas<->present) & (wrapping<->paper)`},
{`stuff`, `stuff`},
{`"her slowly, rubbing the back of his head awkwardly. "`, `(her<->slowly<->rubbing<->the<->back<->of<->his<->head<->awkwardly)`},
}
for i, row := range rows {