diff --git a/src/CrawlerDetect.php b/src/CrawlerDetect.php index 3ea284a..48961d1 100644 --- a/src/CrawlerDetect.php +++ b/src/CrawlerDetect.php @@ -169,6 +169,7 @@ public function isCrawler($userAgent = null) )); if ($agent === '') { + $this->matches = array(); return false; } diff --git a/tests/UserAgentTest.php b/tests/UserAgentTest.php index dd6f265..21bf029 100644 --- a/tests/UserAgentTest.php +++ b/tests/UserAgentTest.php @@ -129,6 +129,16 @@ public function matches_does_not_persit_across_multiple_calls() $this->CrawlerDetect->isCrawler('This should not match'); $matches = $this->CrawlerDetect->getMatches(); $this->assertNull($this->CrawlerDetect->getMatches()); + + //Empty + $this->CrawlerDetect->isCrawler('Mozilla/5.0 (iPhone; CPU iPhone OS 7_1 like Mac OS X) AppleWebKit (KHTML, like Gecko) Mobile (compatible; Yahoo Ad monitoring; https://help.yahoo.com/kb/yahoo-ad-monitoring-SLN24857.html)'); + $this->CrawlerDetect->isCrawler(''); + $this->assertNull($this->CrawlerDetect->getMatches()); + + //Excluded + $this->CrawlerDetect->isCrawler('Mozilla/5.0 (iPhone; CPU iPhone OS 7_1 like Mac OS X) AppleWebKit (KHTML, like Gecko) Mobile (compatible; Yahoo Ad monitoring; https://help.yahoo.com/kb/yahoo-ad-monitoring-SLN24857.html)'); + $this->CrawlerDetect->isCrawler('iPod'); + $this->assertNull($this->CrawlerDetect->getMatches()); } /** @test */