whatwg-fetch
Advanced tools
Comparing version 3.5.0 to 3.6.0
@@ -59,3 +59,3 @@ (function (global, factory) { | ||
if (/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(name) || name === '') { | ||
throw new TypeError('Invalid character in header field name') | ||
throw new TypeError('Invalid character in header field name: "' + name + '"') | ||
} | ||
@@ -256,3 +256,5 @@ return name.toLowerCase() | ||
if (!this.headers.get('content-type')) { | ||
const contentType = this.headers.get('content-type'); | ||
if (!contentType) { | ||
if (typeof body === 'string') { | ||
@@ -265,2 +267,6 @@ this.headers.set('content-type', 'text/plain;charset=UTF-8'); | ||
} | ||
} else if (contentType.includes('json') && typeof this._bodyInit !== 'string') { | ||
// Always pass a text representation of a non-stringified JSON body | ||
// to `XMLHttpRequest.send` to retain a compatible behavior with the browser. | ||
this._bodyInit = this._bodyText; | ||
} | ||
@@ -462,3 +468,3 @@ }; | ||
this.ok = this.status >= 200 && this.status < 300; | ||
this.statusText = 'statusText' in options ? options.statusText : ''; | ||
this.statusText = options.statusText === undefined ? '' : '' + options.statusText; | ||
this.headers = new Headers(options.headers); | ||
@@ -465,0 +471,0 @@ this.url = options.url || ''; |
12
fetch.js
@@ -53,3 +53,3 @@ var global = | ||
if (/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(name) || name === '') { | ||
throw new TypeError('Invalid character in header field name') | ||
throw new TypeError('Invalid character in header field name: "' + name + '"') | ||
} | ||
@@ -250,3 +250,5 @@ return name.toLowerCase() | ||
if (!this.headers.get('content-type')) { | ||
const contentType = this.headers.get('content-type') | ||
if (!contentType) { | ||
if (typeof body === 'string') { | ||
@@ -259,2 +261,6 @@ this.headers.set('content-type', 'text/plain;charset=UTF-8') | ||
} | ||
} else if (contentType.includes('json') && typeof this._bodyInit !== 'string') { | ||
// Always pass a text representation of a non-stringified JSON body | ||
// to `XMLHttpRequest.send` to retain a compatible behavior with the browser. | ||
this._bodyInit = this._bodyText | ||
} | ||
@@ -456,3 +462,3 @@ } | ||
this.ok = this.status >= 200 && this.status < 300 | ||
this.statusText = 'statusText' in options ? options.statusText : '' | ||
this.statusText = options.statusText === undefined ? '' : '' + options.statusText | ||
this.headers = new Headers(options.headers) | ||
@@ -459,0 +465,0 @@ this.url = options.url || '' |
{ | ||
"name": "whatwg-fetch", | ||
"description": "A window.fetch polyfill.", | ||
"version": "3.5.0", | ||
"version": "3.6.0", | ||
"main": "./dist/fetch.umd.js", | ||
@@ -12,4 +12,4 @@ "module": "./fetch.js", | ||
"chai": "^4.1.2", | ||
"eslint": "^4.19.1", | ||
"eslint-plugin-github": "^1.6.0", | ||
"eslint": "^7.20.0", | ||
"eslint-plugin-github": "^4.1.1", | ||
"karma": "^3.0.0", | ||
@@ -16,0 +16,0 @@ "karma-chai": "^0.1.0", |
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
55448
1075