From 6565d24567621a37be627cbfc22c2bde4522b053 Mon Sep 17 00:00:00 2001 From: Faisal Salman Date: Sun, 5 Oct 2025 13:27:17 +0700 Subject: [PATCH] Improve OS detection: iOS 26 --- src/main/ua-parser.js | 15 +++++++++++++-- test/data/ua/os/ios.json | 18 ++++++++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/src/main/ua-parser.js b/src/main/ua-parser.js index b1abedb..e0fdd51 100755 --- a/src/main/ua-parser.js +++ b/src/main/ua-parser.js @@ -1253,8 +1253,19 @@ if (this.itemType != UA_RESULT) { rgxMapper.call(this.data, this.ua, this.rgxMap); } - if (this.itemType == UA_BROWSER) { - this.set(MAJOR, majorize(this.get(VERSION))); + switch (this.itemType) { + case UA_BROWSER: + this.set(MAJOR, majorize(this.get(VERSION))); + break; + case UA_OS: + if (this.get(NAME) == 'iOS' && this.get(VERSION) == '18.6') { + // Based on the assumption that iOS version is tightly coupled with Safari version + var realVersion = /\) Version\/([\d\.]+)/.exec(this.ua); // Get Safari version + if (realVersion && parseInt(realVersion[1].substring(0,2), 10) >= 26) { + this.set(VERSION, realVersion[1]); // Set as iOS version + } + } + break; } return this; }; diff --git a/test/data/ua/os/ios.json b/test/data/ua/os/ios.json index 1b0d636..bf10c3e 100644 --- a/test/data/ua/os/ios.json +++ b/test/data/ua/os/ios.json @@ -1,4 +1,22 @@ [ + { + "desc" : "iOS 18.6", + "ua" : "Mozilla/5.0 (iPhone; CPU iPhone OS 18_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.6 Mobile/15E148 Safari/604.1", + "expect" : + { + "name" : "iOS", + "version" : "18.6" + } + }, + { + "desc" : "iOS 26", + "ua" : "Mozilla/5.0 (iPhone; CPU iPhone OS 18_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1", + "expect" : + { + "name" : "iOS", + "version" : "26.0" + } + }, { "desc" : "iOS in App", "ua" : "AppName/version CFNetwork/version Darwin/version",