3636var lifecycle = {
3737 teardown : function ( ) {
3838 Cookies . defaults = { } ;
39- delete Cookies.raw;
4039 delete Cookies . json ;
4140 Object . keys ( Cookies . get ( ) ) . forEach ( Cookies . remove ) ;
4241 }
@@ -70,26 +69,9 @@ test('RFC 2068 quoted string', function () {
7069 strictEqual ( Cookies . get ( 'c' ) , 'v@address.com"\\"' , 'should decode RFC 2068 quoted string' ) ;
7170} ) ;
7271
73- test('decode', function () {
72+ // github.com/carhartl/jquery-cookie/issues/50
73+ test ( 'equality sign in cookie value' , function ( ) {
7474 expect ( 1 ) ;
75- document.cookie = encodeURIComponent(' c') + '=' + encodeURIComponent(' v');
76- strictEqual(Cookies.get(' c'), ' v', 'should decode key and value');
77- });
78-
79- test('decode pluses to space for server side written cookie', function () {
80- expect(1);
81- document.cookie = 'c=foo+bar';
82- strictEqual(Cookies.get('c'), 'foo bar', 'should convert pluses back to space');
83- });
84-
85- test('raw = true', function () {
86- expect(2);
87- Cookies.raw = true;
88-
89- document.cookie = 'c=%20v';
90- strictEqual(Cookies.get('c'), '%20v', 'should not decode value');
91-
92- // see https://github.com/carhartl/jquery-cookie/issues/50
9375 Cookies . set ( 'c' , 'foo=bar' ) ;
9476 strictEqual ( Cookies . get ( 'c' ) , 'foo=bar' , 'should include the entire value' ) ;
9577} ) ;
@@ -141,13 +123,10 @@ test('invalid JSON string with json = true', function () {
141123 }
142124} ) ;
143125
144- test('invalid URL encoding ', function () {
126+ test ( 'percent character in cookie value ' , function ( ) {
145127 expect ( 1 ) ;
146128 document . cookie = 'bad=foo%' ;
147- strictEqual(Cookies.get('bad'), undefined, "won't throw exception, returns undefined");
148- // Delete manually here because it requires raw === true...
149- Cookies.raw = true;
150- Cookies.remove('bad');
129+ strictEqual ( Cookies . get ( 'bad' ) , 'foo%' , 'should read the percent character' ) ;
151130} ) ;
152131
153132asyncTest ( 'malformed cookie value in IE (#88, #117)' , function ( ) {
@@ -193,17 +172,6 @@ test('Call to read all with json: true', function () {
193172 deepEqual ( Cookies . get ( ) , { c : { foo : 'bar' } } , 'returns JSON parsed cookies' ) ;
194173} ) ;
195174
196- test('Call to read all with a badly encoded cookie', function () {
197- expect(1);
198- document.cookie = 'bad=foo%';
199- document.cookie = 'good=foo';
200- deepEqual(Cookies.get(), { good: 'foo' }, 'returns object containing all decodable cookies');
201- // Delete manually here because it requires raw === true...
202- Cookies.raw = true;
203- Cookies.remove('bad');
204- });
205-
206-
207175module ( 'write' , lifecycle ) ;
208176
209177test ( 'String primitive' , function ( ) {
@@ -282,21 +250,13 @@ test('defaults', function () {
282250 ok ( Cookies . set ( 'c' , 'v' , { path : '/bar' } ) . match ( / p a t h = \/ b a r / ) , 'options argument has precedence' ) ;
283251} ) ;
284252
285- test('raw = true', function () {
286- expect(1);
287- Cookies.raw = true;
288- strictEqual(Cookies.set('c[1]', 'v[1]'), 'c[1]=v[1]', 'should not encode');
289- // Delete manually here because it requires raw === true...
290- Cookies.remove('c[1]');
291- });
292-
293253test ( 'json = true' , function ( ) {
294254 expect ( 1 ) ;
295255 Cookies . json = true ;
296256
297257 if ( 'JSON' in window ) {
298258 Cookies . set ( 'c' , { foo : 'bar' } ) ;
299- strictEqual(document.cookie, 'c=' + encodeURIComponent( JSON.stringify({ foo: 'bar' }) ), 'should stringify JSON');
259+ strictEqual ( document . cookie , 'c=' + JSON . stringify ( { foo : 'bar' } ) , 'should stringify JSON' ) ;
300260 } else {
301261 ok ( true ) ;
302262 }
@@ -341,7 +301,6 @@ test('passing options reference', function () {
341301
342302test ( '[] used in name' , function ( ) {
343303 expect ( 1 ) ;
344- Cookies.raw = true;
345304 document . cookie = 'c[1]=foo' ;
346305 Cookies . remove ( 'c[1]' ) ;
347306 strictEqual ( document . cookie , '' , 'delete the cookie' ) ;
@@ -355,10 +314,3 @@ test('read converter', function() {
355314 Cookies . set ( 'c' , '1' ) ;
356315 strictEqual ( Cookies . get ( 'c' , Number ) , 1 , 'converts read value' ) ;
357316} ) ;
358-
359- test('read converter with raw = true', function() {
360- expect(1);
361- Cookies.raw = true;
362- Cookies.set('c', '1');
363- strictEqual(Cookies.get('c', Number), 1, 'does not decode, but converts read value');
364- });
0 commit comments