From 5a1d6ec14e4a3f32ba5b1295e519a70d37617e1d Mon Sep 17 00:00:00 2001 From: Faisal Salman Date: Mon, 23 Dec 2024 15:29:50 +0700 Subject: [PATCH] Backport - Improve OS detection: fix Linux arch mistakenly detected as version (cherry picked from commit 3ca23193ddc036261b41de75f2263596314641bf) --- src/ua-parser.js | 2 +- test/os-test.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ua-parser.js b/src/ua-parser.js index 1bccc17..8259834 100755 --- a/src/ua-parser.js +++ b/src/ua-parser.js @@ -846,7 +846,7 @@ /(mageia|vectorlinux)[; ]/i, // Mageia/VectorLinux /([kxln]?ubuntu|debian|suse|opensuse|gentoo|arch(?= linux)|slackware|fedora|mandriva|centos|pclinuxos|red ?hat|zenwalk|linpus|raspbian|plan 9|minix|risc os|contiki|deepin|manjaro|elementary os|sabayon|linspire)(?: gnu\/linux)?(?: enterprise)?(?:[- ]linux)?(?:-gnu)?[-\/ ]?(?!chrom|package)([-\w\.]*)/i, // Ubuntu/Debian/SUSE/Gentoo/Arch/Slackware/Fedora/Mandriva/CentOS/PCLinuxOS/RedHat/Zenwalk/Linpus/Raspbian/Plan9/Minix/RISCOS/Contiki/Deepin/Manjaro/elementary/Sabayon/Linspire - /(hurd|linux) ?([\w\.]*)/i, // Hurd/Linux + /(hurd|linux)(?: arm\w*| x86\w*| ?)([\w\.]*)/i, // Hurd/Linux /(gnu) ?([\w\.]*)/i, // GNU /\b([-frentopcghs]{0,5}bsd|dragonfly)[\/ ]?(?!amd|[ix346]{1,2}86)([\w\.]*)/i, // FreeBSD/NetBSD/OpenBSD/PC-BSD/GhostBSD/DragonFly /(haiku) (\w+)/i // Haiku diff --git a/test/os-test.json b/test/os-test.json index 72b5080..1b8b9a4 100644 --- a/test/os-test.json +++ b/test/os-test.json @@ -1103,7 +1103,7 @@ "expect" : { "name" : "Linux", - "version" : "x86_64" + "version" : "undefined" } }, {