this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Parse queries better for search (#579)

Addresses https://github.com/bluesky-social/indigo/issues/578

authored by

Jaz and committed by
GitHub
aabe0b09 a30de45c

+10 -7
+10 -7
search/parse_query.go
··· 8 8 9 9 "github.com/bluesky-social/indigo/atproto/identity" 10 10 "github.com/bluesky-social/indigo/atproto/syntax" 11 - 12 - "github.com/google/shlex" 13 11 ) 14 12 15 13 // ParseQuery takes a query string and pulls out some facet patterns ("from:handle.net") as filters 16 14 func ParseQuery(ctx context.Context, dir identity.Directory, raw string) (string, []map[string]interface{}) { 17 15 var filters []map[string]interface{} 18 - parts, err := shlex.Split(raw) 19 - if err != nil { 20 - // pass-through if failed to parse 21 - return raw, filters 22 - } 16 + quoted := false 17 + parts := strings.FieldsFunc(raw, func(r rune) bool { 18 + if r == '"' { 19 + quoted = !quoted 20 + } 21 + return r == ' ' && !quoted 22 + }) 23 + 23 24 keep := make([]string, len(parts)) 24 25 for _, p := range parts { 26 + p = strings.Trim(p, "\"") 27 + 25 28 if !strings.ContainsRune(p, ':') || strings.ContainsRune(p, ' ') { 26 29 // simple: quoted (whitespace), or just a token 27 30 keep = append(keep, p)