jonathantneal / svg4everybody

Use external SVG spritemaps today
https://jonneal.dev/svg4everybody/
Other
3.29k stars 353 forks source link

`navigator.userAgent` is expected to be a string #178

Open nirazul opened 6 years ago

nirazul commented 6 years ago

I've run into some error reports that I could trace back to these lines of code.

The problem is, that navigator.userAgent is expected to be a string. Some browsers behave differently and allow the user to completely suppress sending a userAgent property at all.

An easy fix would be to set a default value like this:

const ua = navigator.userAgent || '';
ua.match(olderEdgeUA); // <-- this is safe now

I could prepare a PR, if you're ok with the changes.