this is stupid

This commit is contained in:
partisan 2024-06-16 01:30:18 +02:00 committed by partisan
parent f6c68b2cf2
commit 8f58919997

18
text.go
View file

@ -101,9 +101,7 @@ func fetchTextResults(query, safe, lang string, page int) []TextSearchResult {
continue
}
for _, result := range searchResults {
results = append(results, result.(TextSearchResult))
}
results = append(results, validateResults(searchResults)...)
// If results are found, break out of the loop
if len(results) > 0 {
@ -114,6 +112,20 @@ func fetchTextResults(query, safe, lang string, page int) []TextSearchResult {
return results
}
func validateResults(searchResults []SearchResult) []TextSearchResult {
var validResults []TextSearchResult
// Remove anything that is missing a URL or Header
for _, result := range searchResults {
textResult := result.(TextSearchResult)
if textResult.URL != "" || textResult.Header != "" {
validResults = append(validResults, textResult)
}
}
return validResults
}
func wrapTextSearchFunc(f func(string, string, string, int) ([]TextSearchResult, time.Duration, error)) func(string, string, string, int) ([]SearchResult, time.Duration, error) {
return func(query, safe, lang string, page int) ([]SearchResult, time.Duration, error) {
textResults, duration, err := f(query, safe, lang, page)