refactor: create Plain method

pull/12/head
sundowndev 2020-09-05 17:00:13 +02:00
parent 981b9721ed
commit 0971563ddd
2 changed files with 12 additions and 6 deletions

View File

@ -108,8 +108,8 @@ func (e *GoogleSearch) Ext(ext string) *GoogleSearch {
}
// Exclude excludes some results.
func (e *GoogleSearch) Exclude(value string) *GoogleSearch {
e.tags = append(e.tags, e.concat(excludeTag, value, false))
func (e *GoogleSearch) Exclude(tags *GoogleSearch) *GoogleSearch {
e.tags = append(e.tags, e.concat(excludeTag, tags.String(), false))
return e
}
@ -124,3 +124,9 @@ func (e *GoogleSearch) Intitle(value string) *GoogleSearch {
e.tags = append(e.tags, e.concat(intitleTag, value, true))
return e
}
// Plain allows you to add additional values as string without any kind of formatting.
func (e *GoogleSearch) Plain(value string) *GoogleSearch {
e.tags = append(e.tags, value)
return e
}

View File

@ -105,10 +105,10 @@ func TestInit(t *testing.T) {
dork = NewGoogleSearch()
result := dork.
Exclude("html").
Exclude("htm").
Exclude("php").
Exclude("md5sums").
Exclude(NewGoogleSearch().Plain("html")).
Exclude(NewGoogleSearch().Plain("htm")).
Exclude(NewGoogleSearch().Plain("php")).
Exclude(NewGoogleSearch().Plain("md5sums")).
String()
assert.Equal(result, "-html -htm -php -md5sums", "they should be equal")