You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
lancedikson_bowser/src/parser-os.js

54 lines
1.2 KiB

7 years ago
import { getFirstMatch } from './utils';
function getWindowsVersionName(version) {
switch (version) {
case 'NT': return 'NT';
case 'XP': return 'XP';
case 'NT 5.0': return '2000';
case 'NT 5.1': return 'XP';
case 'NT 5.2': return '2003';
case 'NT 6.0': return 'Vista';
case 'NT 6.1': return '7';
case 'NT 6.2': return '8';
case 'NT 6.3': return '8.1';
case 'NT 10.0': return '10';
default: return undefined;
}
}
7 years ago
export default [
{
test: [/windows phone/i],
describe(ua) {
7 years ago
const version = getFirstMatch(/windows phone (?:os)?\s?(\d+(\.\d+)*)/i, ua);
return {
name: 'Windows Phone',
version
}
}
},
{
test: [/windows/i],
describe(ua) {
const version = getFirstMatch(/Windows ((NT|XP)( \d\d?.\d)?)/i, ua);
const versionName = getWindowsVersionName(version);
return {
name: 'Windows',
version,
versionName
};
}
},
7 years ago
{
test: [/macintosh/i],
describe(ua) {
7 years ago
const version = getFirstMatch(/mac os x (\d+([_\s]\d+)*)/i, ua).replace(/[_\s]/g, '.');
return {
name: 'macOS',
version
}
}
}
]