WhichBrowser/Parser-JavaScript

OS Version toString() fails

Closed this issue · 2 comments

TypeError: Cannot read property 'toString' of undefined.

When using Ubuntu desktop info:

ThinkPad-L540 4.4.0-93-generic #116-Ubuntu SMP Fri Aug 11 21:17:51 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

the result.os.version.toString() fails due os.version is undefined. Result object:
Parser { browser: Browser { stock: false, hidden: false, mode: '', type: 'browser', name: 'Firefox', version: Version { hidden: false, value: '55.0' }, family: null }, engine: Engine { name: 'Gecko', version: Version { hidden: false, value: '55.0', details: 3 } }, os: Os { hidden: false, name: 'Ubuntu' }, device: Device { type: 'desktop', subtype: '', identified: 0, generic: true, hidden: false }, camouflage: false, features: [] }

Thanks, i'll try to reproduce

Reproduced.
This behaviour is by design. In order to access the version safely you can use result.os.getVersion(), if the version is present you will receive the os.version.toString() result, otherwise empty string.
If you still need to access to it directly you must check the undefined before invoke toString().

Thanks