WhichBrowser/Parser-PHP

Cannot detect Mac OSX 11.

st8st8 opened this issue · 5 comments

From lines 101 the regex in Analyser/Header/Useragent to detect Max OS X only matches 10 versions.. Version 11 has now been released

    if (preg_match('/Mac OS X (10[0-9\._]*)/u', $ua, $match)) {
                $this->data->os->version = new Version([ 'value' => str_replace('_', '.', $match[1]), 'details' => 2 ]);
            }

            if (preg_match('/;os=Mac (10[0-9[\.,]*)/u', $ua, $match)) {
                $this->data->os->version = new Version([ 'value' => str_replace(',', '.', $match[1]), 'details' => 2 ]);
            }

same issue, can not get osversion.

Mozilla/5.0 (Macintosh; Intel Mac OS X 11_0_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.67 Safari/537.36

Very short term fix for use with version 2.0.42:

if ($whichBrowser->isOs('OS X') && $whichBrowser->os->version === null) { ... }

Doing this makes me feel uneasy. But it's enough for the sake of working out if image/webp should be used or not.

The pull request is still open and I think this can be merged?

The PR has been merged and will be included in the next release.

That said, Safari on Big Sur has fixed the OS version in the user agent string. So it will report macOS Catalina, for example: "You are using Safari 14.0.1 on macOS Catalina 10.15", while I am Big Sur 11.0.1.