Skip to content

Commit

Permalink
AG-34277 Improve 'set-cookie' — add 'essential' and 'nonessential' to…
Browse files Browse the repository at this point in the history
… supported values. #436

Squashed commit of the following:

commit 378ad52
Author: Adam Wróblewski <[email protected]>
Date:   Thu Jul 11 12:35:11 2024 +0200

    Fix typos in test

commit 2d249cf
Author: Adam Wróblewski <[email protected]>
Date:   Thu Jul 11 11:28:09 2024 +0200

    Add new values to 'set-cookie' and 'set-cookie-reload' scriptlets: 'essential', 'nonessential'
  • Loading branch information
AdamWr committed Jul 11, 2024
1 parent 871a0cc commit 977dd80
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/helpers/cookie-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ export const getLimitedCookieValue = (value: string): string | number | null =>
'required',
'hide',
'hidden',
'essential',
'nonessential',
]);

let validValue;
Expand Down
1 change: 1 addition & 0 deletions src/scriptlets/set-cookie-reload.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/scriptlets/set-cookie.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions tests/scriptlets/set-cookie.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]) => {
Expand Down

0 comments on commit 977dd80

Please sign in to comment.