Skip to content

Commit

Permalink
Add allow and deny to set-cookie scriptlet
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamWr committed Jul 18, 2023
1 parent 541473c commit da63052
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ 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`
- 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 da63052

Please sign in to comment.