Skip to content

Commit

Permalink
update PICO OS and Pico devices
Browse files Browse the repository at this point in the history
  • Loading branch information
sanchezzzhak committed Mar 22, 2024
1 parent cb80a0e commit 537c994
Show file tree
Hide file tree
Showing 4 changed files with 243 additions and 48 deletions.
31 changes: 15 additions & 16 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -511,8 +511,7 @@ class DeviceDetector {
* Note: We do not check for browser (family) here, as there might be mobile apps using Chrome, that won't have
* a detected browser, but can still be detected. So we check the useragent for Chrome instead.
*/
if (
deviceType === '' && osFamily === 'Android' && helper.matchUserAgent('Chrome/[.0-9]*', userAgent)) {
if (deviceType === '' && osFamily === 'Android' && helper.matchUserAgent('Chrome/[.0-9]*', userAgent)) {
if (helper.matchUserAgent('(Mobile|eliboM)', userAgent) !== null) {
deviceType = DEVICE_TYPE.SMARTPHONE;
} else{
Expand Down Expand Up @@ -748,10 +747,8 @@ class DeviceDetector {
}

// client hints
if (result.model === '') {
if (clientHints.device && clientHints.device.model !== '') {
result.model = clientHints.device.model;
}
if (result.model === '' && clientHints.device && clientHints.device.model !== '') {
result.model = clientHints.device.model;
}

// device info or deviceTrusted
Expand Down Expand Up @@ -836,15 +833,6 @@ class DeviceDetector {
deviceData,
clientHints
) {
let deviceDataType = this.parseDeviceType(
userAgent,
osData,
clientData,
deviceData,
clientHints
);

deviceData = Object.assign(deviceData, deviceDataType);

/**
* if it's fake UA then it's best not to identify it as Apple running Android OS or GNU/Linux
Expand All @@ -863,6 +851,17 @@ class DeviceDetector {
deviceData.brand = 'Apple';
}

let deviceDataType = this.parseDeviceType(
userAgent,
osData,
clientData,
deviceData,
clientHints
);

deviceData = Object.assign(deviceData, deviceDataType);


if (this.deviceTrusted) {
deviceData.trusted = DeviceTrusted.check(osData, clientData, deviceData, clientHints);
} else {
Expand Down Expand Up @@ -918,7 +917,7 @@ class DeviceDetector {
/**
* detect os, client and device for sync
* @param {string} userAgent - string from request header['user-agent']
* @param clientHints
* @param {{}} clientHints
* @return {DetectResult}
*/
detect(userAgent, clientHints = {}) {
Expand Down
6 changes: 5 additions & 1 deletion parser/device-abstract-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ const COLLECTION_BRAND_IDS = require('./device/brand-short');
const COLLECTION_BRAND_LIST = helper.revertObject(COLLECTION_BRAND_IDS);

const DESKTOP_PATTERN = '(?:Windows (?:NT|IoT)|X11; Linux x86_64)';
const DESKTOP_EXCLUDE_PATTERN = ' Mozilla/|CE-HTML|Andr[o0]id|Tablet|Mobile|iPhone|Windows Phone|OculusBrowser|ricoh|Lenovo|compatible; MSIE|Trident/|Tesla/|XBOX|FBMD/|ARM; ?([^)]+)';
const DESKTOP_EXCLUDE_PATTERN = [
'CE-HTML',
' Mozilla/|Andr[o0]id|Tablet|Mobile|iPhone|Windows Phone|ricoh|OculusBrowser',
'PicoBrowser|Lenovo|compatible; MSIE|Trident/|Tesla/|XBOX|FBMD/|ARM; ?([^)]+)',
].join('|');

class DeviceParserAbstract extends ParserAbstract {
constructor() {
Expand Down
3 changes: 2 additions & 1 deletion parser/os-abstract-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,10 @@ class OsAbstractParser extends ParserAbstract {

if ('PICO OS' === name) {
version = data.version;
short = 'PIC';
}

if (data && 'Fire OS' === data.name) {
if (data && data.name === 'Fire OS') {
let majorVersion = ~~version.split('.', 1)[0];
short = data.short_name;
if (FIREOS_VERSION_MAPPING[version]) {
Expand Down
Loading

0 comments on commit 537c994

Please sign in to comment.