Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 83e1b3e

Browse files
committed
feat(ngCookie): support SameSite option
Closes #16543 Closes #16544
1 parent 627180f commit 83e1b3e

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/ngCookies/cookieWriter.js

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ function $$CookieWriter($document, $log, $browser) {
3333
str += options.domain ? ';domain=' + options.domain : '';
3434
str += expires ? ';expires=' + expires.toUTCString() : '';
3535
str += options.secure ? ';secure' : '';
36+
str += options.SameSite ? ';SameSite=' + options.SameSite : '';
3637

3738
// per http://www.ietf.org/rfc/rfc2109.txt browser must allow at minimum:
3839
// - 300 cookies

test/ngCookies/cookieWriterSpec.js

+10
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,16 @@ describe('cookie options', function() {
181181
expect(getLastCookieAssignment('secure')).toBe(true);
182182
});
183183

184+
it('should accept sameSite option when value is lax', function() {
185+
$$cookieWriter('name', 'value', {SameSite: 'lax'});
186+
expect(getLastCookieAssignment('SameSite')).toBe('lax');
187+
});
188+
189+
it('should accept sameSite option when value is strict', function() {
190+
$$cookieWriter('name', 'value', {SameSite: 'strict'});
191+
expect(getLastCookieAssignment('SameSite')).toBe('strict');
192+
});
193+
184194
it('should accept expires option on set', function() {
185195
$$cookieWriter('name', 'value', {expires: 'Fri, 19 Dec 2014 00:00:00 GMT'});
186196
expect(getLastCookieAssignment('expires')).toMatch(/^Fri, 19 Dec 2014 00:00:00 (UTC|GMT)$/);

0 commit comments

Comments
 (0)