1
0
mirror of https://github.com/lancedikson/bowser synced 2026-10-31 07:46:18 +00:00

fix: stop the Opera version at the last number (#639)

This commit is contained in:
Fuad Laguda
2026-10-27 10:01:56 +00:00
committed by GitHub
parent d0c26eceeb
commit c220b2bf1c
3 changed files with 28 additions and 1 deletions

View File

@@ -451,7 +451,8 @@ const browsersList = [
const browser = {
name: 'Opera',
};
const version = Utils.getFirstMatch(/(?:opr|opios)[\s/](\S+)/i, ua) || Utils.getFirstMatch(commonVersionIdentifier, ua);
// Numbers and dots only, so a suffix like OPR/82.0.4227.58/VoplfMPIL3LW69FfgZ stays out of the version
const version = Utils.getFirstMatch(/(?:opr|opios)[\s/](\d+(?:\.\d+)*)/i, ua) || Utils.getFirstMatch(commonVersionIdentifier, ua);
if (version) {
browser.version = version;

View File

@@ -529,6 +529,20 @@
name: "WebKit"
version: "533.16"
Opera:
-
ua: "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36 OPR/82.0.4227.58/VoplfMPIL3LW69FfgZ"
spec:
browser:
name: "Opera"
version: "82.0.4227.58"
os:
name: "Windows"
version: "NT 10.0"
versionName: "10"
platform:
type: "desktop"
engine:
name: "Blink"
-
ua: "Mozilla/5.0 (Linux; Android 4.4.2; Nexus 7 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.72 Safari/537.36 OPR/19.0.1340.69721"
spec:

View File

@@ -87,6 +87,18 @@ test('Skip parsing shouldn\'t parse', (t) => {
t.deepEqual((new Parser(UA, true)).getResult(), {});
});
test('Parser reads the Opera version without a trailing suffix', (t) => {
const p = new Parser('Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36 OPR/82.0.4227.58/VoplfMPIL3LW69FfgZ');
t.is(p.getBrowserVersion(), '82.0.4227.58');
t.is(p.satisfies({ opera: '>=80' }), true);
});
test('Parser reads a one-number Opera version', (t) => {
const p = new Parser('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36 OPR/9');
t.is(p.getBrowserVersion(), '9');
t.is(p.satisfies({ opera: '>=8' }), true);
});
test('Parser.satisfies should make simple comparisons', (t) => {
// also covers Parser.compareVersion() and Parser.compareVersions() methods
t.is(parser.satisfies({ opera: '>42' }), true);