bowser icon indicating copy to clipboard operation
bowser copied to clipboard

Requesting New Feature for OS parser

Open krishnaTORQUE opened this issue 3 years ago • 0 comments

This is how I get OS from User Agent. I request author to use this code to improve OS parser for better & accurate result.

List Order is very important for accurate result

  const osList: any = {
    'windows nt 10': 'Windows 10',
    'windows nt 6.3': 'Windows 8.1',
    'windows nt 6.2': 'Windows 8',
    'windows nt 6.1': 'Windows 7',
    'windows nt 6.0': 'Windows Vista',
    'windows nt 5.2': 'Windows Server 2003/XP x64',
    'windows nt 5.1': 'Windows XP',
    'windows xp': 'Windows XP',
    'windows nt 5.0': 'Windows 2000',
    'windows me': 'Windows ME',
    win98: 'Windows 98',
    win95: 'Windows 95',
    win16: 'Windows 3.11',
    mac_powerpc: 'Mac OS 9',
    'macintosh|mac os x': 'Mac OS X',
    'Red Hat': 'Red Hat',
    ubuntu: 'Ubuntu',
    fedora: 'Fedora',
    android: 'Android',
    linux: 'Linux',
    iphone: 'iPhone',
    ipod: 'iPod',
    ipad: 'iPad',
    blackberry: 'BlackBerry',
    'webos|wos': 'Mobile',
  };

  let theOs: string = 'Other';
  for (const os in osList) {
    if (agent.match(new RegExp(os, 'gmi'))) {
      theOs = osList[os];
      break;
    }
  }

  return theOs;
};

krishnaTORQUE avatar Nov 07 '21 17:11 krishnaTORQUE