1
0
mirror of https://github.com/lancedikson/bowser synced 2026-03-02 03:40:27 +00:00

Add OS parsing

This commit is contained in:
Denis Demchenko
2017-04-15 22:46:18 +03:00
parent c50d0449d3
commit b057077b68
3 changed files with 81 additions and 3 deletions

24
src/parser-os.js Normal file
View File

@@ -0,0 +1,24 @@
import { getFirstMatch } from './utils';
export default [
{
test: [/windows phone/i],
detect(ua) {
const version = getFirstMatch(/windows phone (?:os)?\s?(\d+(\.\d+)*)/i, ua);
return {
name: 'Windows Phone',
version
}
}
},
{
test: [/macintosh/i],
detect(ua) {
const version = getFirstMatch(/mac os x (\d+([_\s]\d+)*)/i, ua).replace(/[_\s]/g, '.');
return {
name: 'macOS',
version
}
}
}
]