Handle undefined device names
This commit is contained in:
parent
dcf46bd600
commit
4b15aa0417
1 changed files with 14 additions and 4 deletions
|
@ -208,11 +208,21 @@ class Peer {
|
|||
let ua = parser(req.headers['user-agent']);
|
||||
|
||||
|
||||
let deviceName = ua.os.name.replace('Mac OS', 'Mac') + ' ';
|
||||
if (ua.device.model) {
|
||||
deviceName += ua.device.model;
|
||||
let deviceName = '';
|
||||
|
||||
if (ua.os && ua.os.name) {
|
||||
deviceName = ua.os.name.replace('Mac OS', 'Mac') + ' ';
|
||||
}
|
||||
|
||||
if(ua.device){
|
||||
if (ua.device.model) {
|
||||
deviceName += ua.device.model;
|
||||
} else {
|
||||
deviceName += ua.browser.name;
|
||||
}
|
||||
} else {
|
||||
deviceName += ua.browser.name;
|
||||
if(!deviceName)
|
||||
deviceName = 'Unknown Device';
|
||||
}
|
||||
|
||||
const displayName = uniqueNamesGenerator({
|
||||
|
|
Loading…
Reference in a new issue