Improve OS detection: iOS 26

This commit is contained in:
Faisal Salman
2025-10-05 13:27:17 +07:00
parent b3281b7c12
commit 6565d24567
2 changed files with 31 additions and 2 deletions

View File

@@ -1253,8 +1253,19 @@
if (this.itemType != UA_RESULT) { if (this.itemType != UA_RESULT) {
rgxMapper.call(this.data, this.ua, this.rgxMap); rgxMapper.call(this.data, this.ua, this.rgxMap);
} }
if (this.itemType == UA_BROWSER) { switch (this.itemType) {
this.set(MAJOR, majorize(this.get(VERSION))); 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; return this;
}; };

View File

@@ -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", "desc" : "iOS in App",
"ua" : "AppName/version CFNetwork/version Darwin/version", "ua" : "AppName/version CFNetwork/version Darwin/version",