pub fn create_is_bot(custom_pattern: Regex) -> impl Fn(&str) -> boolExpand description
Creates a closure that checks if a user agent string matches a custom regex pattern
§Arguments
custom_pattern- ARegexobject that represents the custom pattern to be used for matching.
§Returns
Returns a closure that takes a user agent string as input and returns true if the user agent matches the
custom regex pattern and is not empty, or false otherwise.
let pattern = Regex::new(r"Googlebot").unwrap();
let custom_bot = create_is_bot(pattern);
assert!(custom_bot("Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)"));