Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fetch-detector

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fetch-detector - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

44

index.js

@@ -1,26 +0,28 @@

// 检测浏览器版本,并设置 window.__disableNativeFetch 来决定是否开启 fetch
var userAgent = navigator.userAgent || "";
var appVersion = navigator.appVersion || "";
var vendor = navigator.vendor || "";
if (navigator && navigator.userAgent) {
// 检测浏览器版本,并设置 window.__disableNativeFetch 来决定是否开启 fetch
var userAgent = navigator.userAgent || "";
var appVersion = navigator.appVersion || "";
var vendor = navigator.vendor || "";
var ua = (userAgent + ' ' + appVersion + ' ' + vendor).toLowerCase();
var ua = (userAgent + ' ' + appVersion + ' ' + vendor).toLowerCase();
var match = /(chrome)[ \/]([\w.]+)/.exec(ua)
|| /(webkit)[ \/]([\w.]+)/.exec(ua)
|| /(opera)(?:.*version|)[ \/]([\w.]+)/.exec(ua)
|| /(msie) ([\w.]+)/.exec(ua)
|| /(trident)(?:.*? rv:([\w.]+)|)/.exec(ua)
|| ua.indexOf("compatible") < 0
&& /(mozilla)(?:.*? rv:([\w.]+)|)/.exec(ua) || [];
var match = /(chrome)[ \/]([\w.]+)/.exec(ua)
|| /(webkit)[ \/]([\w.]+)/.exec(ua)
|| /(opera)(?:.*version|)[ \/]([\w.]+)/.exec(ua)
|| /(msie) ([\w.]+)/.exec(ua)
|| /(trident)(?:.*? rv:([\w.]+)|)/.exec(ua)
|| ua.indexOf("compatible") < 0
&& /(mozilla)(?:.*? rv:([\w.]+)|)/.exec(ua) || [];
var engine = match[0];
var mainVersion = match[2].split('.')[0];
var engine = match[0];
var mainVersion = match[2].split('.')[0];
// chrome 内核版本大于 46, firefox 版本大于39 才开启 fetch
if (engine.indexOf('chrome') === 0 && mainVersion >= 46) {
window.__disableNativeFetch = false;
} else if (engine.indexOf('mozilla') === 0 && mainVersion >= 39) {
window.__disableNativeFetch = false;
} else {
window.__disableNativeFetch = true;
// chrome 内核版本大于 46, firefox 版本大于39 才开启 fetch
if (engine.indexOf('chrome') === 0 && mainVersion >= 46) {
window.__disableNativeFetch = false;
} else if (engine.indexOf('mozilla') === 0 && mainVersion >= 39) {
window.__disableNativeFetch = false;
} else {
window.__disableNativeFetch = true;
}
}
{
"name": "fetch-detector",
"version": "1.0.0",
"version": "1.0.1",
"description": "Detector fetch based on browser version",

@@ -5,0 +5,0 @@ "main": "index.js",

## Fetch Detector
有些浏览器虽然支持 Fetch API 但不完整,如 Chrome 45 和 Firefox 33 版本 response
中的[中文会乱码](https://lists.w3.org/Archives/Public/public-webapps-github/2015Aug/0218.html)。本库的作用是只在 Chrome >= 46,Firefox >= 39 时才开启原生
中的[中文会乱码](https://code.google.com/p/chromium/issues/detail?id=511289)[2](https://code.google.com/p/chromium/issues/detail?id=516931)。本库的作用是只在 Chrome >= 46,Firefox >= 39 时才开启原生
Fetch,否则使用 XHR polyfill。

@@ -9,3 +9,5 @@

```
npm install 'fetch-detector'
```

@@ -16,3 +18,3 @@ ## Usage

```
```js
import 'fetch-detector'

@@ -22,1 +24,3 @@ import 'fetch-ie8'

## License
MIT
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc