fix spaced quotes causing weird behavior in search.
continuous-integration/drone/push Build is passing
continuous-integration/drone/push Build is passing
This commit is contained in:
+16
-10
@@ -17,28 +17,34 @@ func TSQueryFromSearch(search string) string {
|
|||||||
startQuotes := false
|
startQuotes := false
|
||||||
|
|
||||||
if strings.HasPrefix(token, "\"") {
|
if strings.HasPrefix(token, "\"") {
|
||||||
token = token[1:]
|
if len(token) > 1 {
|
||||||
|
token = token[1:]
|
||||||
|
}
|
||||||
startQuotes = true
|
startQuotes = true
|
||||||
}
|
}
|
||||||
if strings.HasSuffix(token, "\"") {
|
if strings.HasSuffix(token, "\"") {
|
||||||
token = token[:len(token)-1]
|
token = token[:len(token)-1]
|
||||||
|
startQuotes = false
|
||||||
clearQuotes = true
|
clearQuotes = true
|
||||||
}
|
}
|
||||||
|
|
||||||
if startQuotes {
|
token := strings.Trim(token, ",.;:()\"")
|
||||||
if i > 0 {
|
if len(token) > 0 {
|
||||||
|
if startQuotes {
|
||||||
|
if i > 0 {
|
||||||
|
result += " & "
|
||||||
|
}
|
||||||
|
|
||||||
|
result += "("
|
||||||
|
} else if inQuotes {
|
||||||
|
result += "<->"
|
||||||
|
} else if i != 0 {
|
||||||
result += " & "
|
result += " & "
|
||||||
}
|
}
|
||||||
|
|
||||||
result += "("
|
result += token
|
||||||
} else if inQuotes {
|
|
||||||
result += "<->"
|
|
||||||
} else if i != 0 {
|
|
||||||
result += " & "
|
|
||||||
}
|
}
|
||||||
|
|
||||||
result += token
|
|
||||||
|
|
||||||
if startQuotes {
|
if startQuotes {
|
||||||
inQuotes = true
|
inQuotes = true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ func TestTSQueryFromSearch(t *testing.T) {
|
|||||||
{`"asari matron" blue`, `(asari<->matron) & blue`},
|
{`"asari matron" blue`, `(asari<->matron) & blue`},
|
||||||
{`"christmas present" "wrapping paper"`, `(christmas<->present) & (wrapping<->paper)`},
|
{`"christmas present" "wrapping paper"`, `(christmas<->present) & (wrapping<->paper)`},
|
||||||
{`stuff`, `stuff`},
|
{`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 {
|
for i, row := range rows {
|
||||||
|
|||||||
Reference in New Issue
Block a user