photoprism/pkg/http/header/bots.go
Michael Mayer a921f82a17 Pkg: Move /service/http/... to /http/... and add package /http/dns
Signed-off-by: Michael Mayer <michael@photoprism.app>
2025-10-19 21:08:48 +02:00

32 lines
627 B
Go

package header
import (
"fmt"
"regexp"
"strings"
)
// Bots contains common search engine bot names.
var Bots = []string{
"Googlebot",
"PetalBot",
"Bingbot",
"DuckDuckBot",
"Yahoo! Slurp",
"Baiduspider",
"Bytespider",
"YandexBot",
"Sogou",
"Exabot",
"Applebot",
"facebot",
"github-camo",
}
// BotsRegexp matches common search engine bot names.
var BotsRegexp = regexp.MustCompile(fmt.Sprintf("(%s)", strings.Join(Bots, "|")))
// IsBot checks whether the specified user agent string probably belongs to a search engine bot.
func IsBot(userAgent string) bool {
return BotsRegexp.FindString(userAgent) != ""
}