Skip to content

Commit

Permalink
AG-23747 Fix 'set-cookie' — add 'allow' and 'deny' values. #336
Browse files Browse the repository at this point in the history
Squashed commit of the following:

commit ee6e1f3
Author: Slava Leleka <v.leleka@adguard.com>
Date:   Tue Jul 18 15:41:49 2023 +0300

    update changelog

commit da63052
Author: Adam Wróblewski <adam@adguard.com>
Date:   Tue Jul 18 14:25:06 2023 +0200

    Add `allow` and `deny` to set-cookie scriptlet
  • Loading branch information
AdamWr committed Jul 18, 2023
1 parent 541473c commit 6f36f88
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- new values to `set-cookie` and `set-cookie-reload` scriptlets: `Accept`, `Reject`, `y`, `n`, `N`, `No`
[#336](https://github.com/AdguardTeam/Scriptlets/issues/336)
- new values to `set-cookie` and `set-cookie-reload` scriptlets: `Accept`, `Reject`, `y`, `n`, `N`, `No`,
`allow`, `deny` [#336](https://github.com/AdguardTeam/Scriptlets/issues/336)
- ability to use flags in regular expression scriptlet parameters
[#303](https://github.com/AdguardTeam/Scriptlets/issues/303)

Expand Down
1 change: 1 addition & 0 deletions src/helpers/cookie-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export const getLimitedCookieValue = (value: string): string | number | null =>
'n', 'N',
'ok', 'OK',
'Accept', 'Reject',
'allow', 'deny',
]);

let validValue;
Expand Down
14 changes: 14 additions & 0 deletions tests/scriptlets/set-cookie.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,20 @@ test('Set cookie with valid value', (assert) => {
assert.strictEqual(document.cookie.includes(cName) && document.cookie.includes(cValue), true, 'Cookie is set');
clearCookie(cName);

cName = '__test-cookie_allow';
cValue = 'allow';
runScriptlet(name, [cName, cValue]);
assert.strictEqual(window.hit, 'FIRED', 'Hit was fired');
assert.strictEqual(document.cookie.includes(cName) && document.cookie.includes(cValue), true, 'Cookie is set');
clearCookie(cName);

cName = '__test-cookie_deny';
cValue = 'deny';
runScriptlet(name, [cName, cValue]);
assert.strictEqual(window.hit, 'FIRED', 'Hit was fired');
assert.strictEqual(document.cookie.includes(cName) && document.cookie.includes(cValue), true, 'Cookie is set');
clearCookie(cName);

cName = '__test-cookie_0';
cValue = '0';
runScriptlet(name, [cName, cValue]);
Expand Down

0 comments on commit 6f36f88

Please sign in to comment.