this is stupid
This commit is contained in:
parent
87ac6f05f9
commit
8f3f1e2d3e
1 changed files with 15 additions and 3 deletions
18
text.go
18
text.go
|
@ -101,9 +101,7 @@ func fetchTextResults(query, safe, lang string, page int) []TextSearchResult {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, result := range searchResults {
|
results = append(results, validateResults(searchResults)...)
|
||||||
results = append(results, result.(TextSearchResult))
|
|
||||||
}
|
|
||||||
|
|
||||||
// If results are found, break out of the loop
|
// If results are found, break out of the loop
|
||||||
if len(results) > 0 {
|
if len(results) > 0 {
|
||||||
|
@ -114,6 +112,20 @@ func fetchTextResults(query, safe, lang string, page int) []TextSearchResult {
|
||||||
return results
|
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) {
|
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) {
|
return func(query, safe, lang string, page int) ([]SearchResult, time.Duration, error) {
|
||||||
textResults, duration, err := f(query, safe, lang, page)
|
textResults, duration, err := f(query, safe, lang, page)
|
||||||
|
|
Loading…
Add table
Reference in a new issue