Skip to content

Commit

Permalink
Improve version parsing on old browsers by removing regex from versio…
Browse files Browse the repository at this point in the history
…n parts split
  • Loading branch information
MarioBotDuComptoirDesPharmacies committed Dec 14, 2020
1 parent cffc927 commit e3ba146
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,8 @@ export function parseUserAgent(
if (name === 'searchbot') {
return new BotInfo();
}
let versionParts = match[1] && match[1].split(/[._]/).slice(0, 3);
// Do not use RegExp for split operation as some browser do not support it (See: http://blog.stevenlevithan.com/archives/cross-browser-split)
let versionParts = match[1] && match[1].split('.').join('_').split('_').slice(0, 3);
if (versionParts) {
if (versionParts.length < REQUIRED_VERSION_PARTS) {
versionParts = [
Expand Down

0 comments on commit e3ba146

Please sign in to comment.