Skip to content

Commit

Permalink
当ua的参数不是正常的 user-agent 字符串的时候,new UA 会直接抛出脚本错误,这次修改对非字符串的参数做了兼容,当传入非法…
Browse files Browse the repository at this point in the history
…参数的时候静默返回,保障decect结果可以正常使用
  • Loading branch information
norfish committed Apr 18, 2017
1 parent 3a8af53 commit 3da3bb9
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/useragent-base.js
Original file line number Diff line number Diff line change
Expand Up @@ -2558,6 +2558,12 @@ module.exports = (function () {

detect: function (ua) {

// when ua is not a string, just do not detect it slient
if(typeof ua !== 'string') {
// throw new TypeError('ua must be a string')
return this;
}

/****************************************************
* Unix
*/
Expand Down

0 comments on commit 3da3bb9

Please sign in to comment.