Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Requesting New Feature for OS parser #498

Open
krishnaTORQUE opened this issue Nov 7, 2021 · 0 comments
Open

Requesting New Feature for OS parser #498

krishnaTORQUE opened this issue Nov 7, 2021 · 0 comments

Comments

@krishnaTORQUE
Copy link

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 krishnaTORQUE changed the title Requesting New Feature for OS Requesting New Feature for OS parser Nov 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant