Skip to content

Commit

Permalink
fix ubo-adg conversion of remove param
Browse files Browse the repository at this point in the history
  • Loading branch information
slavaleleka committed Feb 21, 2024
1 parent b273341 commit 20dbb9d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ The format is based on [Keep a Changelog], and this project adheres to [Semantic

- Validation of scriptlet rules with no name and args for multiple scriptlet exception rules [#377]

### Fixed

- UBO→ADG conversion of `$remove$` scriptlet param [#404]

[Unreleased]: https://github.com/AdguardTeam/Scriptlets/compare/v1.10.1...HEAD
[#404]: https://github.com/AdguardTeam/Scriptlets/issues/404
[#377]: https://github.com/AdguardTeam/Scriptlets/issues/377

## [v1.10.1] - 2024-02-12
Expand Down
4 changes: 4 additions & 0 deletions src/helpers/converter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,10 @@ export const convertUboScriptletToAdg = (rule: string): string[] => {
if (arg === '$') {
outputArg = '$$';
}
// https://github.com/AdguardTeam/Scriptlets/issues/404
if (arg === '$remove$') {
outputArg = '$$remove$$';
}
return outputArg;
})
.map((arg) => wrapInSingleQuotes(arg))
Expand Down
10 changes: 10 additions & 0 deletions tests/api/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,11 @@ describe('Test scriptlet api methods', () => {
// eslint-disable-next-line max-len
expected: "example.com#%#//scriptlet('ubo-spoof-css.js', '.adsbygoogle, #ads, .adTest', 'visibility', 'visible')",
},
// https://github.com/AdguardTeam/Scriptlets/issues/404
{
actual: 'example.com##+js(set-local-storage-item, mode, $remove$)',
expected: "example.com#%#//scriptlet('ubo-set-local-storage-item.js', 'mode', '$remove$')",
},
];
test.each(validTestCases)('$actual', ({ actual, expected }) => {
expect(convertScriptletToAdg(actual)[0]).toStrictEqual(expected);
Expand Down Expand Up @@ -351,6 +356,11 @@ describe('Test scriptlet api methods', () => {
actual: "example.com#%#//scriptlet('set-cookie-reload', 'consent', 'true')",
expected: 'example.com##+js(set-cookie-reload, consent, true)',
},
// https://github.com/AdguardTeam/Scriptlets/issues/404
{
actual: "example.com#%#//scriptlet('set-local-storage-item', 'mode', '$remove$')",
expected: 'example.com##+js(set-local-storage-item, mode, $remove$)',
},
];
test.each(testCases)('$actual', ({ actual, expected }) => {
expect(convertAdgScriptletToUbo(actual)).toStrictEqual(expected);
Expand Down

0 comments on commit 20dbb9d

Please sign in to comment.