Skip to content

Commit

Permalink
Merge pull request #972 from Gaurav0/gaurav/feat/support_partitioned_…
Browse files Browse the repository at this point in the history
…cookies

Support Partitioned Cookies
  • Loading branch information
BobrImperator authored Nov 1, 2024
2 parents eaff044 + ea8d1d4 commit 65e5e40
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 51 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"start:addon": "pnpm --filter ember-cookies start",
"start:test-app": "pnpm --filter test-app start",
"test": "pnpm run test:test-app ember-default",
"test:all": "pnpm --filter test-app test:all",
"test:test-app": "pnpm --filter test-app test:one",
"test:watch": "concurrently \"pnpm test:watch:test-app\" \"pnpm test:watch:addon\"",
"test:watch:addon": "pnpm --filter ember-cookies start",
Expand Down
3 changes: 3 additions & 0 deletions packages/ember-cookies/src/utils/serialize-cookie.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ export const serializeCookie = (name, value, options = {}) => {
if (!isEmpty(options.sameSite)) {
cookie = `${cookie}; SameSite=${options.sameSite}`;
}
if (options.partitioned) {
cookie = `${cookie}; Partitioned`;
}

return cookie;
};
2 changes: 1 addition & 1 deletion packages/test-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"ember-cli-inject-live-reload": "2.1.0",
"ember-cli-sri": "2.1.1",
"ember-cli-terser": "4.0.2",
"ember-cookies": "1.1.2",
"ember-cookies": "link:../ember-cookies",
"ember-disable-prototype-extensions": "1.1.3",
"ember-load-initializers": "2.1.2",
"ember-maybe-import-regenerator": "1.0.0",
Expand Down
11 changes: 11 additions & 0 deletions packages/test-app/tests/unit/services/cookies-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,17 @@ module('CookiesService', function (hooks) {
this.cookies.write(COOKIE_NAME, 'test', { secure: true });
});

test('sets the partitioned flag', function (assert) {
assert.expect(1);
defineProperty(this.fakeDocument, 'cookie', {
set(value) {
assert.ok(value.includes('; Partitioned'));
},
});

this.cookies.write(COOKIE_NAME, 'test', { partitioned: true });
});

test('sets the path', function (assert) {
assert.expect(1);
defineProperty(this.fakeDocument, 'cookie', {
Expand Down
54 changes: 4 additions & 50 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 65e5e40

Please sign in to comment.