Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

当传入的 user-agent 不是字符串的时候,内部没有处理,导致抛出脚本错误 #21

Open
wants to merge 0 commits into
base: master
Choose a base branch
from

Conversation

norfish
Copy link

@norfish norfish commented Apr 18, 2017

ua的参数不是正常的 user-agent 字符串的时候,new UA 会直接抛出脚本错误,这次修改对非字符串的参数做了兼容,当传入非法参数的时候静默返回,确保decect结果可以正常使用

另外这一行我不确定要不要加上 // throw new TypeError('ua must be a string')
是否需要抛出一个自定义的Type Error出来,我倾向于不抛出来。因为ua-device是个第三方库,应该对用户传入的参数做各种兼容处理,而不是直接抛出错误,导致用户进程 crash 掉

@norfish norfish changed the title 当传入的 user-agent 不是字符串的时候,没有处理,会抛出脚本错误 当传入的 user-agent 不是字符串的时候,内部没有处理,导致抛出脚本错误 Apr 18, 2017
@kevindu1993
Copy link
Contributor

嗯,你说的很对,确实没有注意数据类型判断的问题,平时我在用它的时候是在外层包的try catch,所以就没在内部进行对应的处理

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants