hgoebl / mobile-detect.js

Device detection (phone, tablet, desktop, mobile grade, os, versions)
http://hgoebl.github.io/mobile-detect.js/
MIT License
4.12k stars 892 forks source link

Method substr is undefined (fix) #77

Closed dan-on closed 6 years ago

dan-on commented 6 years ago

Hello!

The current build of your project, returns an error: "Uncaught TypeError: (a || "").substr is not a function"

hgoebl commented 6 years ago

It's a bit more complicated. I suppose you get the error because the user-agent string is not string, but undefined, null or something else. substr is not a new function and it should be available to string instances even in very old browsers. The semantics between substr and substring is not equal. So even if this pull request was merged, it would probably break, at least one of the changes.

Where do you get the error message?

dan-on commented 6 years ago

You're right! I accidentally passed an object to the constructor.

Excuse me. Thank for the quick answer.

hgoebl commented 6 years ago

No problem, at least I've learned the subtle difference between both functions :-)