Repository navigation
Closed
Description
I recently tried to use this library for parsing a bunch of user-agents but it crashed for the following one:
Mozilla/5.0 (Linux; U; Android 4.1.1; en-us; O+ 8.36 Android Build/Oplus8.36_Oplus) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30
I used the following code, which worked just fine on many user-agents before crashing on the one I mentioned above:
'use strict';
const WhichBrowser = require('which-browser');
const useragent = 'Mozilla/5.0 (Linux; U; Android 4.1.1; en-us; O+ 8.36 Android Build/Oplus8.36_Oplus) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30';
// It is using a hard-coded user agent here, but this is how I was successfully using the library with other
// user-agents
const info = new WhichBrowser(useragent, {
cache: WhichBrowser.SIMPLE_CACHE,
cacheExpires: 90
});
console.log('Done!');Here is the error:
/home/user/test/which-browser/node_modules/which-browser/src/data/DeviceModels.js:200
for (let m2 of Object.keys(list[v] || list[originalV])) {
^
TypeError: Cannot convert undefined or null to object
at Function.keys (<anonymous>)
at Function.identifyList (/home/user/test/which-browser/node_modules/which-browser/src/data/DeviceModels.js:200:39)
at Function.identifyAndroid (/home/user/test/which-browser/node_modules/which-browser/src/data/DeviceModels.js:145:33)
at Function.identify (/home/user/test/which-browser/node_modules/which-browser/src/data/DeviceModels.js:25:29)
at Useragent.detectAndroid (/home/user/test/which-browser/node_modules/which-browser/src/Analyser/Header/Useragent/Os.js:325:35)
at Useragent.detectOperatingSystem (/home/user/test/which-browser/node_modules/which-browser/src/Analyser/Header/Useragent/Os.js:20:22)
at new Useragent (/home/user/test/which-browser/node_modules/which-browser/src/Analyser/Header/Useragent.js:13:30)
at Analyser.analyseUserAgent (/home/user/test/which-browser/node_modules/which-browser/src/Analyser/Header.js:74:5)
at Analyser.analyseHeaders (/home/user/test/which-browser/node_modules/which-browser/src/Analyser/Header.js:11:31)
at Analyser.analyse (/home/user/test/which-browser/node_modules/which-browser/src/Analyser.js:45:27)
I also noticed something interesting: the user-agent mentioned above can be successfully parsed by https://whichbrowser.net/tryout/
Metadata
Metadata
Assignees
Labels
No labels
Activity
mariotsi commentedon Dec 6, 2017
Thanks for the issue. I'll try to investigate this.
mariotsi commentedon Dec 6, 2017
Found the problem. Thanks for pointing it out. I'll fix asap
Added test case in order to reproduce issue #10 and relative fix
Added test case in order to reproduce issue #10 and relative fix
mariotsi commentedon Dec 7, 2017
Version
0.2.5is out, fixes this issue and contains updates for the database and the detection system (thanks @NielsLeenheer ).@stouf thanks for reporting this issue and for using this library.
Enjoy!
stouf commentedon Dec 7, 2017
@mariotsi Thanks a lot for taking such quick actions, much appreciated :)
Merge pull request #10 from koconder/dependabot/npm_and_yarn/prettier…