Skip to content

Commit

Permalink
fixed jshttp#5 ignore escape error and return original value better t…
Browse files Browse the repository at this point in the history
…han throw the error.
  • Loading branch information
fengmk2 committed Oct 29, 2012
1 parent e86c424 commit 1ae8966
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 5 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@ var parse = function(str) {

// only assign once
if (undefined == obj[key]) {
obj[key] = decode(val);
try {
obj[key] = decode(val);
} catch (e) {
obj[key] = val;
}
}
});

Expand Down
3 changes: 3 additions & 0 deletions test/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,6 @@ test('escaping', function() {
cookie.parse('email=%20%22%2c%3b%2f'));
});

test('ignore escaping error and return original value', function() {
assert.deepEqual({ foo: '%1', bar: 'bar' }, cookie.parse('foo=%1;bar=bar'));
});

0 comments on commit 1ae8966

Please sign in to comment.