2017-07-14 00:22:02 +00:00
|
|
|
/**
|
|
|
|
|
* @license
|
2020-05-19 19:08:49 +00:00
|
|
|
* Copyright Google LLC All Rights Reserved.
|
2017-07-14 00:22:02 +00:00
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by an MIT-style license that can be
|
2024-09-20 15:23:15 +00:00
|
|
|
* found in the LICENSE file at https://angular.dev/license
|
2017-07-14 00:22:02 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
2020-04-13 23:40:21 +00:00
|
|
|
* @license
|
2020-05-19 19:08:49 +00:00
|
|
|
* Copyright Google LLC All Rights Reserved.
|
2020-04-13 23:40:21 +00:00
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by an MIT-style license that can be
|
2024-09-20 15:23:15 +00:00
|
|
|
* found in the LICENSE file at https://angular.dev/license
|
2020-04-13 23:40:21 +00:00
|
|
|
*/
|
2017-07-14 00:22:02 +00:00
|
|
|
|
|
|
|
|
import {parseCookieValue} from '../src/cookie';
|
|
|
|
|
|
2023-10-17 09:45:16 +00:00
|
|
|
describe('cookies', () => {
|
|
|
|
|
it('parses cookies', () => {
|
|
|
|
|
const cookie = 'other-cookie=false; xsrf-token=token-value; is_awesome=true; ffo=true;';
|
|
|
|
|
expect(parseCookieValue(cookie, 'xsrf-token')).toBe('token-value');
|
2017-07-14 00:22:02 +00:00
|
|
|
});
|
2023-10-17 09:45:16 +00:00
|
|
|
it('handles encoded keys', () => {
|
|
|
|
|
expect(parseCookieValue('whitespace%20token=token-value', 'whitespace token')).toBe(
|
|
|
|
|
'token-value',
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
it('handles encoded values', () => {
|
|
|
|
|
expect(parseCookieValue('token=whitespace%20', 'token')).toBe('whitespace ');
|
|
|
|
|
expect(parseCookieValue('token=whitespace%0A', 'token')).toBe('whitespace\n');
|
|
|
|
|
});
|
|
|
|
|
});
|