processTokens takes the split tokens and groups them based on a delimiter (':'). Tokens without a delimiter present are joined to support searching with spaces. Example Input: ['deprecated:false', 'test', 'template'] Example Output: ['deprecated:false', 'test template']
(tokens []string)
| 835 | // Example Input: ['deprecated:false', 'test', 'template'] |
| 836 | // Example Output: ['deprecated:false', 'test template'] |
| 837 | func processTokens(tokens []string) []string { |
| 838 | var results []string |
| 839 | var nonFieldTerms []string |
| 840 | for _, token := range tokens { |
| 841 | if strings.Contains(token, string(':')) { |
| 842 | results = append(results, token) |
| 843 | } else { |
| 844 | nonFieldTerms = append(nonFieldTerms, token) |
| 845 | } |
| 846 | } |
| 847 | if len(nonFieldTerms) > 0 { |
| 848 | results = append(results, strings.Join(nonFieldTerms, " ")) |
| 849 | } |
| 850 | return results |
| 851 | } |