diff --git a/fetch.js b/fetch.js index 06e4d1dc..018bbb36 100644 --- a/fetch.js +++ b/fetch.js @@ -44,7 +44,7 @@ function normalizeName(name) { if (typeof name !== 'string') { name = String(name) } - if (/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(name)) { + if (/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(name) || name === '') { throw new TypeError('Invalid character in header field name') } return name.toLowerCase() diff --git a/test/test.js b/test/test.js index a09ac4ad..1bebef88 100644 --- a/test/test.js +++ b/test/test.js @@ -262,6 +262,9 @@ exercise.forEach(function(exerciseMode) { var headers = new Headers() headers.set({field: 'value'}, 'application/json') }, TypeError) + assert.throws(function() { + new Headers({'': 'application/json'}) + }, TypeError) }) featureDependent(test, !brokenFF, 'is iterable with forEach', function() { var headers = new Headers()