snapdrop

A Progressive Web App for local file sharing
git clone http://git.hanabi.in/repos/snapdrop.git
Log | Files | Refs | README | LICENSE

commit 4b15aa04173871b08d13c3737ec5ba9921833812
parent dcf46bd6008172687109bd2d51ecf90f21b037da
Author: RobinLinus <robinlinus@users.noreply.github.com>
Date:   Wed, 10 Mar 2021 15:25:03 +0100

Handle undefined device names

Diffstat:
Mserver/index.js | 18++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/server/index.js b/server/index.js @@ -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({