fix ts query getting mad at you for quoting a single word.
This commit is contained in:
@@ -16,16 +16,15 @@ func TSQueryFromSearch(search string) string {
|
|||||||
clearQuotes := false
|
clearQuotes := false
|
||||||
startQuotes := false
|
startQuotes := false
|
||||||
|
|
||||||
if strings.HasPrefix(token, "\"") {
|
if strings.HasPrefix(token, "\"") && len(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]
|
if !startQuotes {
|
||||||
|
clearQuotes = true
|
||||||
|
}
|
||||||
|
|
||||||
startQuotes = false
|
startQuotes = false
|
||||||
clearQuotes = true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
token := strings.Trim(token, ",.;:()\"")
|
token := strings.Trim(token, ",.;:()\"")
|
||||||
|
|||||||
@@ -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`},
|
||||||
|
{`"stuff"`, `stuff`},
|
||||||
{`"her slowly, rubbing the back of his head awkwardly. "`, `(her<->slowly<->rubbing<->the<->back<->of<->his<->head<->awkwardly)`},
|
{`"her slowly, rubbing the back of his head awkwardly. "`, `(her<->slowly<->rubbing<->the<->back<->of<->his<->head<->awkwardly)`},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user