Skip to content

Commit

Permalink
field name can not by empty
Browse files Browse the repository at this point in the history
  • Loading branch information
justjavac committed Dec 29, 2018
1 parent 1821b74 commit 96b37eb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion fetch.js
Expand Up @@ -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 === '') {

This comment has been minimized.

Copy link
@elijahjamz

elijahjamz May 19, 2020

Try that

throw new TypeError('Invalid character in header field name')
}
return name.toLowerCase()

This comment has been minimized.

Copy link
@elijahjamz

elijahjamz May 19, 2020

You like

Expand Down
3 changes: 3 additions & 0 deletions test/test.js
Expand Up @@ -262,6 +262,9 @@ exercise.forEach(function(exerciseMode) {
var headers = new Headers()

This comment has been minimized.

Copy link
@williamcasto1970

williamcasto1970 Jun 3, 2019

nice

This comment has been minimized.

Copy link
@iloveqianhuiliu

iloveqianhuiliu Jul 23, 2019

Is there any Chinese?

This comment has been minimized.

Copy link
@Ron-star

Ron-star Oct 13, 2019

Is there any Chinese?

none

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()
Expand Down

0 comments on commit 96b37eb

Please sign in to comment.