whatwg-fetch
Advanced tools
Comparing version 3.1.1 to 3.2.0
@@ -5,10 +5,14 @@ (function (global, factory) { | ||
(factory((global.WHATWGFetch = {}))); | ||
}(this, (function (exports) { 'use strict'; | ||
}(this, (function (exports) { | ||
var global = (function(self) { | ||
return self | ||
// eslint-disable-next-line no-invalid-this | ||
})(typeof self !== 'undefined' ? self : this); | ||
var support = { | ||
searchParams: 'URLSearchParams' in self, | ||
iterable: 'Symbol' in self && 'iterator' in Symbol, | ||
searchParams: 'URLSearchParams' in global, | ||
iterable: 'Symbol' in global && 'iterator' in Symbol, | ||
blob: | ||
'FileReader' in self && | ||
'Blob' in self && | ||
'FileReader' in global && | ||
'Blob' in global && | ||
(function() { | ||
@@ -22,4 +26,4 @@ try { | ||
})(), | ||
formData: 'FormData' in self, | ||
arrayBuffer: 'ArrayBuffer' in self | ||
formData: 'FormData' in global, | ||
arrayBuffer: 'ArrayBuffer' in global | ||
}; | ||
@@ -365,2 +369,17 @@ | ||
this._initBody(body); | ||
if (this.method === 'GET' || this.method === 'HEAD') { | ||
if (options.cache === 'no-store' || options.cache === 'no-cache') { | ||
// Search for a '_' parameter in the query string | ||
var reParamSearch = /([?&])_=[^&]*/; | ||
if (reParamSearch.test(this.url)) { | ||
// If it already exists then set the value with the current time | ||
this.url = this.url.replace(reParamSearch, '$1_=' + new Date().getTime()); | ||
} else { | ||
// Otherwise add a new '_' parameter to the end with the current time | ||
var reQueryString = /\?/; | ||
this.url += (reQueryString.test(this.url) ? '&' : '?') + '_=' + new Date().getTime(); | ||
} | ||
} | ||
} | ||
} | ||
@@ -447,6 +466,5 @@ | ||
exports.DOMException = self.DOMException; | ||
try { | ||
new exports.DOMException(); | ||
} catch (err) { | ||
exports.DOMException = global.DOMException; | ||
if (typeof exports.DOMException !== 'function') { | ||
exports.DOMException = function(message, name) { | ||
@@ -509,3 +527,3 @@ this.message = message; | ||
try { | ||
return url === '' && self.location.href ? self.location.href : url | ||
return url === '' && global.location.href ? global.location.href : url | ||
} catch (e) { | ||
@@ -557,7 +575,7 @@ return url | ||
if (!self.fetch) { | ||
self.fetch = fetch; | ||
self.Headers = Headers; | ||
self.Request = Request; | ||
self.Response = Response; | ||
if (!global.fetch) { | ||
global.fetch = fetch; | ||
global.Headers = Headers; | ||
global.Request = Request; | ||
global.Response = Response; | ||
} | ||
@@ -564,0 +582,0 @@ |
50
fetch.js
@@ -0,7 +1,11 @@ | ||
var global = (function(self) { | ||
return self | ||
// eslint-disable-next-line no-invalid-this | ||
})(typeof self !== 'undefined' ? self : this) | ||
var support = { | ||
searchParams: 'URLSearchParams' in self, | ||
iterable: 'Symbol' in self && 'iterator' in Symbol, | ||
searchParams: 'URLSearchParams' in global, | ||
iterable: 'Symbol' in global && 'iterator' in Symbol, | ||
blob: | ||
'FileReader' in self && | ||
'Blob' in self && | ||
'FileReader' in global && | ||
'Blob' in global && | ||
(function() { | ||
@@ -15,4 +19,4 @@ try { | ||
})(), | ||
formData: 'FormData' in self, | ||
arrayBuffer: 'ArrayBuffer' in self | ||
formData: 'FormData' in global, | ||
arrayBuffer: 'ArrayBuffer' in global | ||
} | ||
@@ -358,2 +362,17 @@ | ||
this._initBody(body) | ||
if (this.method === 'GET' || this.method === 'HEAD') { | ||
if (options.cache === 'no-store' || options.cache === 'no-cache') { | ||
// Search for a '_' parameter in the query string | ||
var reParamSearch = /([?&])_=[^&]*/ | ||
if (reParamSearch.test(this.url)) { | ||
// If it already exists then set the value with the current time | ||
this.url = this.url.replace(reParamSearch, '$1_=' + new Date().getTime()) | ||
} else { | ||
// Otherwise add a new '_' parameter to the end with the current time | ||
var reQueryString = /\?/ | ||
this.url += (reQueryString.test(this.url) ? '&' : '?') + '_=' + new Date().getTime() | ||
} | ||
} | ||
} | ||
} | ||
@@ -440,6 +459,5 @@ | ||
export var DOMException = self.DOMException | ||
try { | ||
new DOMException() | ||
} catch (err) { | ||
export var DOMException = global.DOMException | ||
if (typeof DOMException !== 'function') { | ||
DOMException = function(message, name) { | ||
@@ -502,3 +520,3 @@ this.message = message | ||
try { | ||
return url === '' && self.location.href ? self.location.href : url | ||
return url === '' && global.location.href ? global.location.href : url | ||
} catch (e) { | ||
@@ -550,7 +568,7 @@ return url | ||
if (!self.fetch) { | ||
self.fetch = fetch | ||
self.Headers = Headers | ||
self.Request = Request | ||
self.Response = Response | ||
if (!global.fetch) { | ||
global.fetch = fetch | ||
global.Headers = Headers | ||
global.Request = Request | ||
global.Response = Response | ||
} |
{ | ||
"name": "whatwg-fetch", | ||
"description": "A window.fetch polyfill.", | ||
"version": "3.1.1", | ||
"version": "3.2.0", | ||
"main": "./dist/fetch.umd.js", | ||
@@ -6,0 +6,0 @@ "module": "./fetch.js", |
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
51553
995