Skip to content

Commit 091921f

Browse files
Provide a solution for custom decoding
1 parent 7bc2135 commit 091921f

1 file changed

Lines changed: 19 additions & 1 deletion

File tree

‎test/tests.js‎

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,25 @@ test('json = true', function () {
262262
}
263263
});
264264

265+
// github.com/carhartl/jquery-cookie/pull/62
266+
test('provide a way for decoding PHP whitespace encoding', function () {
267+
expect(1);
268+
document.cookie = 'c=foo+bar';
269+
var actual = Cookies.get('c', function (value) {
270+
return value.replace(/\+/g, ' ');
271+
});
272+
strictEqual(actual, 'foo bar', 'should convert pluses back to space');
273+
});
274+
275+
// github.com/carhartl/jquery-cookie/pull/166
276+
test('provide a way for decoding chinese characters', function () {
277+
expect(1);
278+
document.cookie = 'c=%u5317%u4eac';
279+
var actual = Cookies.get('c', function (value) {
280+
return unescape(value);
281+
});
282+
strictEqual(actual, '北京', 'should convert chinese characters correctly');
283+
});
265284

266285
module('removeCookie', lifecycle);
267286

@@ -306,7 +325,6 @@ test('[] used in name', function () {
306325
strictEqual(document.cookie, '', 'delete the cookie');
307326
});
308327

309-
310328
module('conversion', lifecycle);
311329

312330
test('read converter', function() {

0 commit comments

Comments
 (0)