Skip to content

Commit 8930e2e

Browse files
method to return the bot that matched
1 parent edd1c67 commit 8930e2e

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/Middleware/BlockBots.php

+13-1
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,24 @@ private function isAllowedBot()
9797
return preg_match($pattern, $userAgent);
9898
}
9999

100+
/**
101+
* @return mixed|string|null
102+
*/
103+
public function getMatchedBot()
104+
{
105+
foreach (array_keys($this->getAllowedBots()) as $bot) {
106+
if (strpos(strtolower($this->client->userAgent), strtolower($bot)) !== false) {
107+
return $bot;
108+
}
109+
}
110+
}
111+
100112
/**
101113
* Check if the client is whitelisted.
102114
*
103115
* @return bool
104116
*/
105-
private function isWhitelisted()
117+
public function isWhitelisted()
106118
{
107119
if (Redis::sismember($this->options->whitelist_key, $this->client->ip)) {
108120
return true;

0 commit comments

Comments
 (0)