Skip to content

Commit aeb69c6

Browse files
committed
pref: ignore empty http tokens
1 parent 57a6f6c commit aeb69c6

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

HISTORY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
unreleased
22
==========
33

4+
* pref: ignore empty http tokens
45
* deps: http-errors@~1.8.1
56
- deps: inherits@2.0.4
67
- deps: toidentifier@1.0.1

index.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1096,7 +1096,9 @@ function parseTokenList (str) {
10961096
}
10971097
break
10981098
case 0x2c: /* , */
1099-
list.push(str.substring(start, end))
1099+
if (start !== end) {
1100+
list.push(str.substring(start, end))
1101+
}
11001102
start = end = i + 1
11011103
break
11021104
default:
@@ -1106,7 +1108,9 @@ function parseTokenList (str) {
11061108
}
11071109

11081110
// final token
1109-
list.push(str.substring(start, end))
1111+
if (start !== end) {
1112+
list.push(str.substring(start, end))
1113+
}
11101114

11111115
return list
11121116
}

test/send.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ describe('send(file).pipe(res)', function () {
451451
it('should respond with 412 when ETag unmatched', function (done) {
452452
request(app)
453453
.get('/name.txt')
454-
.set('If-Match', ' "foo", "bar" ')
454+
.set('If-Match', ' "foo",, "bar" ,')
455455
.expect(412, done)
456456
})
457457

0 commit comments

Comments
 (0)