From 977dd80610d1b1d66f1db594ae6e6ced2ccf81b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20Wr=C3=B3blewski?= Date: Thu, 11 Jul 2024 15:07:46 +0300 Subject: [PATCH] =?UTF-8?q?AG-34277=20Improve=20'set-cookie'=20=E2=80=94?= =?UTF-8?q?=20add=20'essential'=20and=20'nonessential'=20to=20supported=20?= =?UTF-8?q?values.=20#436?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Squashed commit of the following: commit 378ad521469fedef3177486e6bc1f899d353c666 Author: Adam Wróblewski Date: Thu Jul 11 12:35:11 2024 +0200 Fix typos in test commit 2d249cf6884abb61f42707bf5b151dea89a4ff5b Author: Adam Wróblewski Date: Thu Jul 11 11:28:09 2024 +0200 Add new values to 'set-cookie' and 'set-cookie-reload' scriptlets: 'essential', 'nonessential' --- CHANGELOG.md | 2 ++ src/helpers/cookie-utils.ts | 2 ++ src/scriptlets/set-cookie-reload.js | 1 + src/scriptlets/set-cookie.js | 1 + tests/scriptlets/set-cookie.test.js | 6 ++++-- 5 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4c09c718..632750e1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,9 +11,11 @@ The format is based on [Keep a Changelog], and this project adheres to [Semantic ### Added +- new values to `set-cookie` and `set-cookie-reload` scriptlets: `essential`, `nonessential` [#436] - `trusted-set-session-storage-item` scriptlet [#426] [Unreleased]: https://github.com/AdguardTeam/Scriptlets/compare/v1.11.6...HEAD +[#436]: https://github.com/AdguardTeam/Scriptlets/issues/436 [#426]: https://github.com/AdguardTeam/Scriptlets/issues/426 ## [v1.11.6] - 2024-07-08 diff --git a/src/helpers/cookie-utils.ts b/src/helpers/cookie-utils.ts index d0ef37ff..fab3e488 100644 --- a/src/helpers/cookie-utils.ts +++ b/src/helpers/cookie-utils.ts @@ -106,6 +106,8 @@ export const getLimitedCookieValue = (value: string): string | number | null => 'required', 'hide', 'hidden', + 'essential', + 'nonessential', ]); let validValue; diff --git a/src/scriptlets/set-cookie-reload.js b/src/scriptlets/set-cookie-reload.js index 256f99b1..5e669d88 100644 --- a/src/scriptlets/set-cookie-reload.js +++ b/src/scriptlets/set-cookie-reload.js @@ -43,6 +43,7 @@ import { * - `disable` / `disabled` * - `necessary` / `required` * - `hide` / `hidden` + * - `essential` / `nonessential` * - `path` — optional, cookie path, defaults to `/`; possible values: * - `/` — root path * - `none` — to set no path at all diff --git a/src/scriptlets/set-cookie.js b/src/scriptlets/set-cookie.js index a9b2a032..5c82c16e 100644 --- a/src/scriptlets/set-cookie.js +++ b/src/scriptlets/set-cookie.js @@ -45,6 +45,7 @@ import { * - `disable` / `disabled` * - `necessary` / `required` * - `hide` / `hidden` + * - `essential` / `nonessential` * - `path` — optional, cookie path, defaults to `/`; possible values: * - `/` — root path * - `none` — to set no path at all diff --git a/tests/scriptlets/set-cookie.test.js b/tests/scriptlets/set-cookie.test.js index 3a225178..b5576886 100644 --- a/tests/scriptlets/set-cookie.test.js +++ b/tests/scriptlets/set-cookie.test.js @@ -66,8 +66,10 @@ const cookies = [ ['__test-cookie_disabled', 'disabled'], ['__test-cookie_necessary', 'necessary'], ['__test-cookie_required', 'required'], - ['__test-cookie_required', 'hide'], - ['__test-cookie_required', 'hidden'], + ['__test-cookie_hide', 'hide'], + ['__test-cookie_hidden', 'hidden'], + ['__test-cookie_essential', 'essential'], + ['__test-cookie_nonessential', 'nonessential'], ]; test.each('Set cookie with valid value', cookies, (assert, [cName, cValue]) => {