Skip to content

Commit a1ceb81

Browse files
committed
Add tab char from BWS def
1 parent 96c30a8 commit a1ceb81

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

index.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,16 +145,18 @@ function parse(str, options) {
145145

146146
function startIndex(str, index, max) {
147147
do {
148-
if (str.charCodeAt(index) !== 0x20 /* */) break;
148+
var code = str.charCodeAt(index);
149+
if (code !== 0x20 /* */ && code !== 0x09 /* \t */) return index;
149150
} while (++index < max);
150-
return index;
151+
return max;
151152
}
152153

153154
function endIndex(str, index, min) {
154155
while (index > min) {
155-
if (str.charCodeAt(--index) !== 0x20 /* */) return index + 1;
156+
var code = str.charCodeAt(--index);
157+
if (code !== 0x20 /* */ && code !== 0x09 /* \t */) return index + 1;
156158
}
157-
return index;
159+
return min;
158160
}
159161

160162
/**

test/parse.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ describe('cookie.parse(str)', function () {
4646
assert.deepEqual(cookie.parse(' = bar '), { '': 'bar' })
4747
assert.deepEqual(cookie.parse(' foo = '), { foo: '' })
4848
assert.deepEqual(cookie.parse(' = '), { '': '' })
49+
assert.deepEqual(cookie.parse('\tfoo\t=\tbar\t'), { foo: 'bar' })
4950
})
5051

5152
it('should return original value on escape error', function () {

0 commit comments

Comments
 (0)