detect-browser
Advanced tools
Comparing version 5.2.0 to 5.2.1
@@ -1,7 +0,9 @@ | ||
var __spreadArrays = (this && this.__spreadArrays) || function () { | ||
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; | ||
for (var r = Array(s), k = 0, i = 0; i < il; i++) | ||
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) | ||
r[k] = a[j]; | ||
return r; | ||
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { | ||
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { | ||
if (ar || !(i in from)) { | ||
if (!ar) ar = Array.prototype.slice.call(from, 0, i); | ||
ar[i] = from[i]; | ||
} | ||
} | ||
return to.concat(ar || Array.prototype.slice.call(from)); | ||
}; | ||
@@ -62,3 +64,3 @@ var BrowserInfo = /** @class */ (function () { | ||
var SEARCHBOX_UA_REGEX = /alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/; | ||
var SEARCHBOT_OS_REGEX = /(nuhk|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\ Jeeves\/Teoma|ia_archiver)/; | ||
var SEARCHBOT_OS_REGEX = /(nuhk|curl|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\ Jeeves\/Teoma|ia_archiver)/; | ||
var REQUIRED_VERSION_PARTS = 3; | ||
@@ -95,6 +97,7 @@ var userAgentRules = [ | ||
['safari', /Version\/([0-9\._]+).*Safari/], | ||
['facebook', /FBAV\/([0-9\.]+)/], | ||
['facebook', /FB[AS]V\/([0-9\.]+)/], | ||
['instagram', /Instagram\s([0-9\.]+)/], | ||
['ios-webview', /AppleWebKit\/([0-9\.]+).*Mobile/], | ||
['ios-webview', /AppleWebKit\/([0-9\.]+).*Gecko\)$/], | ||
['curl', /^curl\/([0-9\.]+)$/], | ||
['searchbot', SEARCHBOX_UA_REGEX], | ||
@@ -171,6 +174,7 @@ ]; | ||
} | ||
var 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) | ||
var versionParts = match[1] && match[1].split('.').join('_').split('_').slice(0, 3); | ||
if (versionParts) { | ||
if (versionParts.length < REQUIRED_VERSION_PARTS) { | ||
versionParts = __spreadArrays(versionParts, createVersionParts(REQUIRED_VERSION_PARTS - versionParts.length)); | ||
versionParts = __spreadArray(__spreadArray([], versionParts, true), createVersionParts(REQUIRED_VERSION_PARTS - versionParts.length), true); | ||
} | ||
@@ -177,0 +181,0 @@ } |
@@ -44,3 +44,3 @@ /// <reference types="node" /> | ||
} | ||
export declare type Browser = 'aol' | 'edge' | 'edge-ios' | 'yandexbrowser' | 'kakaotalk' | 'samsung' | 'silk' | 'miui' | 'beaker' | 'edge-chromium' | 'chrome' | 'chromium-webview' | 'phantomjs' | 'crios' | 'firefox' | 'fxios' | 'opera-mini' | 'opera' | 'ie' | 'bb10' | 'android' | 'ios' | 'safari' | 'facebook' | 'instagram' | 'ios-webview' | 'searchbot'; | ||
export declare type Browser = 'aol' | 'edge' | 'edge-ios' | 'yandexbrowser' | 'kakaotalk' | 'samsung' | 'silk' | 'miui' | 'beaker' | 'edge-chromium' | 'chrome' | 'chromium-webview' | 'phantomjs' | 'crios' | 'firefox' | 'fxios' | 'opera-mini' | 'opera' | 'ie' | 'bb10' | 'android' | 'ios' | 'safari' | 'facebook' | 'instagram' | 'ios-webview' | 'curl' | 'searchbot'; | ||
export declare type OperatingSystem = 'iOS' | 'Android OS' | 'BlackBerry OS' | 'Windows Mobile' | 'Amazon OS' | 'Windows 3.11' | 'Windows 95' | 'Windows 98' | 'Windows 2000' | 'Windows XP' | 'Windows Server 2003' | 'Windows Vista' | 'Windows 7' | 'Windows 8' | 'Windows 8.1' | 'Windows 10' | 'Windows ME' | 'Open BSD' | 'Sun OS' | 'Linux' | 'Mac OS' | 'QNX' | 'BeOS' | 'OS/2' | 'Chrome OS'; | ||
@@ -47,0 +47,0 @@ export declare function detect(userAgent?: string): BrowserInfo | SearchBotDeviceInfo | BotInfo | NodeInfo | ReactNativeInfo | null; |
25
index.js
"use strict"; | ||
var __spreadArrays = (this && this.__spreadArrays) || function () { | ||
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; | ||
for (var r = Array(s), k = 0, i = 0; i < il; i++) | ||
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) | ||
r[k] = a[j]; | ||
return r; | ||
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { | ||
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { | ||
if (ar || !(i in from)) { | ||
if (!ar) ar = Array.prototype.slice.call(from, 0, i); | ||
ar[i] = from[i]; | ||
} | ||
} | ||
return to.concat(ar || Array.prototype.slice.call(from)); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getNodeVersion = exports.detectOS = exports.parseUserAgent = exports.browserName = exports.detect = exports.ReactNativeInfo = exports.BotInfo = exports.SearchBotDeviceInfo = exports.NodeInfo = exports.BrowserInfo = void 0; | ||
var BrowserInfo = /** @class */ (function () { | ||
@@ -64,3 +67,3 @@ function BrowserInfo(name, version, os) { | ||
var SEARCHBOX_UA_REGEX = /alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/; | ||
var SEARCHBOT_OS_REGEX = /(nuhk|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\ Jeeves\/Teoma|ia_archiver)/; | ||
var SEARCHBOT_OS_REGEX = /(nuhk|curl|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\ Jeeves\/Teoma|ia_archiver)/; | ||
var REQUIRED_VERSION_PARTS = 3; | ||
@@ -97,6 +100,7 @@ var userAgentRules = [ | ||
['safari', /Version\/([0-9\._]+).*Safari/], | ||
['facebook', /FBAV\/([0-9\.]+)/], | ||
['facebook', /FB[AS]V\/([0-9\.]+)/], | ||
['instagram', /Instagram\s([0-9\.]+)/], | ||
['ios-webview', /AppleWebKit\/([0-9\.]+).*Mobile/], | ||
['ios-webview', /AppleWebKit\/([0-9\.]+).*Gecko\)$/], | ||
['curl', /^curl\/([0-9\.]+)$/], | ||
['searchbot', SEARCHBOX_UA_REGEX], | ||
@@ -175,6 +179,7 @@ ]; | ||
} | ||
var 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) | ||
var versionParts = match[1] && match[1].split('.').join('_').split('_').slice(0, 3); | ||
if (versionParts) { | ||
if (versionParts.length < REQUIRED_VERSION_PARTS) { | ||
versionParts = __spreadArrays(versionParts, createVersionParts(REQUIRED_VERSION_PARTS - versionParts.length)); | ||
versionParts = __spreadArray(__spreadArray([], versionParts, true), createVersionParts(REQUIRED_VERSION_PARTS - versionParts.length), true); | ||
} | ||
@@ -181,0 +186,0 @@ } |
{ | ||
"name": "detect-browser", | ||
"version": "5.2.0", | ||
"version": "5.2.1", | ||
"description": "Unpack a browser type and version from the useragent string", | ||
@@ -50,4 +50,4 @@ "main": "index.js", | ||
"tslint": "^6.1.3", | ||
"typescript": "^3.6.2" | ||
"typescript": "^4.4.3" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
26323
481