Skip to content

Commit 2655226

Browse files
committed
Improve regexes
1 parent 597a745 commit 2655226

File tree

13 files changed

+1392
-1392
lines changed

13 files changed

+1392
-1392
lines changed

DeviceDetector.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -776,7 +776,7 @@ protected function getOsAttribute(string $attr): string
776776
*/
777777
protected function hasAndroidTableFragment(): bool
778778
{
779-
$regex = 'Android( [\.0-9]+)?; Tablet;|Tablet(?! PC)|.*\-tablet$';
779+
$regex = 'Android( [.0-9]+)?; Tablet;|Tablet(?! PC)|.*\-tablet$';
780780

781781
return !!$this->matchUserAgent($regex);
782782
}
@@ -788,7 +788,7 @@ protected function hasAndroidTableFragment(): bool
788788
*/
789789
protected function hasAndroidMobileFragment(): bool
790790
{
791-
$regex = 'Android( [\.0-9]+)?; Mobile;|.*\-mobile$';
791+
$regex = 'Android( [.0-9]+)?; Mobile;|.*\-mobile$';
792792

793793
return !!$this->matchUserAgent($regex);
794794
}
@@ -800,7 +800,7 @@ protected function hasAndroidMobileFragment(): bool
800800
*/
801801
protected function hasAndroidVRFragment(): bool
802802
{
803-
$regex = 'Android( [\.0-9]+)?; Mobile VR;| VR ';
803+
$regex = 'Android( [.0-9]+)?; Mobile VR;| VR ';
804804

805805
return !!$this->matchUserAgent($regex);
806806
}
@@ -959,7 +959,7 @@ protected function parseDevice(): void
959959
* a detected browser, but can still be detected. So we check the useragent for Chrome instead.
960960
*/
961961
if (null === $this->device && 'Android' === $osFamily
962-
&& $this->matchUserAgent('Chrome/[\.0-9]*')
962+
&& $this->matchUserAgent('Chrome/[.0-9]*')
963963
) {
964964
if ($this->matchUserAgent('(?:Mobile|eliboM)')) {
965965
$this->device = AbstractDeviceParser::DEVICE_TYPE_SMARTPHONE;

Parser/Client/Browser/Engine/Version.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function parse(): ?array
4949
}
5050

5151
if ('Gecko' === $this->engine || 'Clecko' === $this->engine) {
52-
$pattern = '~[ ](?:rv[: ]([0-9\.]+)).*(?:g|cl)ecko/[0-9]{8,10}~i';
52+
$pattern = '~[ ](?:rv[: ]([0-9.]+)).*(?:g|cl)ecko/[0-9]{8,10}~i';
5353

5454
if (\preg_match($pattern, $this->userAgent, $matches)) {
5555
return ['version' => \array_pop($matches)];

Parser/Device/ShellTv.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class ShellTv extends AbstractDeviceParser
3636
*/
3737
public function isShellTv(): bool
3838
{
39-
$regex = '[a-z]+[ _]Shell[ _]\w{6}|tclwebkit(\d+[\.\d]*)';
39+
$regex = '[a-z]+[ _]Shell[ _]\w{6}|tclwebkit(\d+[.\d]*)';
4040
$match = $this->matchUserAgent($regex);
4141

4242
return null !== $match;

regexes/bots.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -981,7 +981,7 @@
981981
name: ''
982982
url: 'https://ip-guide.com'
983983

984-
- regex: 'k6/[0-9\.]+'
984+
- regex: 'k6/[0-9.]+'
985985
name: 'K6'
986986
url: 'https://k6.io/'
987987

0 commit comments

Comments
 (0)