From ac72ad4516acfb456b029de4cbcfc4c735008b09 Mon Sep 17 00:00:00 2001 From: jellizaveta Date: Wed, 21 Aug 2024 17:24:51 +0300 Subject: [PATCH] =?UTF-8?q?AG-35299=20Improve=20'set-cookie'=20=E2=80=94?= =?UTF-8?q?=20add=20'checked'=20and=20'unchecked'=20to=20supported=20value?= =?UTF-8?q?s.=20#444?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 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 | 2 ++ 5 files changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 778b12f63..7b5b7057b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,9 +13,11 @@ The format is based on [Keep a Changelog], and this project adheres to [Semantic - support for matching line number in `abort-on-stack-trace` scriptlet when `inlineScript` or `injectedScript` option is used [#439] +- new values to `set-cookie` and `set-cookie-reload` scriptlets: `checked`, `unchecked` [#444] [Unreleased]: https://github.com/AdguardTeam/Scriptlets/compare/v1.11.16...HEAD [#439]: https://github.com/AdguardTeam/Scriptlets/issues/439 +[#444]: https://github.com/AdguardTeam/Scriptlets/issues/444 ## [v1.11.16] - 2024-08-01 diff --git a/src/helpers/cookie-utils.ts b/src/helpers/cookie-utils.ts index fab3e4881..8cff2caa5 100644 --- a/src/helpers/cookie-utils.ts +++ b/src/helpers/cookie-utils.ts @@ -108,6 +108,8 @@ export const getLimitedCookieValue = (value: string): string | number | null => 'hidden', 'essential', 'nonessential', + 'checked', + 'unchecked', ]); let validValue; diff --git a/src/scriptlets/set-cookie-reload.js b/src/scriptlets/set-cookie-reload.js index 5e669d886..c421d5b2f 100644 --- a/src/scriptlets/set-cookie-reload.js +++ b/src/scriptlets/set-cookie-reload.js @@ -44,6 +44,7 @@ import { * - `necessary` / `required` * - `hide` / `hidden` * - `essential` / `nonessential` + * - `checked` / `unchecked` * - `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 5c82c16ec..392bb6de3 100644 --- a/src/scriptlets/set-cookie.js +++ b/src/scriptlets/set-cookie.js @@ -46,6 +46,7 @@ import { * - `necessary` / `required` * - `hide` / `hidden` * - `essential` / `nonessential` + * - `checked` / `unchecked` * - `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 b55768863..e1a6fb466 100644 --- a/tests/scriptlets/set-cookie.test.js +++ b/tests/scriptlets/set-cookie.test.js @@ -70,6 +70,8 @@ const cookies = [ ['__test-cookie_hidden', 'hidden'], ['__test-cookie_essential', 'essential'], ['__test-cookie_nonessential', 'nonessential'], + ['__test-cookie_checked', 'checked'], + ['__test-cookie_unchecked', 'unchecked'], ]; test.each('Set cookie with valid value', cookies, (assert, [cName, cValue]) => {