Skip to content

Commit

Permalink
Merge pull request in ADGUARD-FILTERS/compiler from bug_fixes to master
Browse files Browse the repository at this point in the history
* commit '48b9cb827c3c70713733d66e1ced348b7728539e':
  modified multi cnversion case
  fixed abp scriptlets multi conversion case - pushed converted rule into result and continue
  fixed abp scriptlets multi conversion case
  convert array to string
  updated version to 1.0.43
  fixed scriptlets conversion
  • Loading branch information
Oleg Labudko committed Feb 6, 2020
2 parents ffe765d + 48b9cb8 commit 0f94285
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "adguard-filters-compiler",
"version": "1.0.42",
"version": "1.0.43",
"description": "Adguard filters compiler",
"homepage": "http://adguard.com",
"dependencies": {
Expand Down
5 changes: 3 additions & 2 deletions src/main/converter.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,15 @@ module.exports = (() => {
}

// Convert UBO and ABP scriptlets to AdGuard scriptlets
if (!rule.startsWith('!') && !rule.startsWith('#') && (scriptlets.isUboScriptletRule(rule) || scriptlets.isAbpSnippetRule(rule))) {
if (!rule.startsWith(RuleMasks.MASK_COMMENT) && (scriptlets.isUboScriptletRule(rule) || scriptlets.isAbpSnippetRule(rule))) {
const convertedRule = scriptlets.convertScriptletToAdg(rule);
if (!convertedRule) {
logger.error(`Unable to convert scriptlet to Adguard syntax: "${rule}" `);
rule = `! Inconvertible scriptlet: ${rule}`;
} else {
logger.log(`Rule "${rule}" converted to: ${convertedRule}`);
rule = convertedRule;
result.push(...convertedRule);
continue;
}
}

Expand Down
7 changes: 7 additions & 0 deletions src/test/test-converter.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,13 @@ QUnit.test('Test scriptlets lib converter', (assert) => {
actual = scriptlets.convertScriptletToAdg('test.com#$#abort-on-property-read adsShown');
expected = 'test.com#%#//scriptlet("abp-abort-on-property-read", "adsShown")';
assert.equal(actual, expected);

actual = scriptlets.convertScriptletToAdg('example.org#$#hide-if-has-and-matches-style \'d[id^="_"]\' \'div > s\' \'display: none\'; hide-if-contains /.*/ .p \'a[href^="/ad__c?"]\'');
expected = [
'example.org#%#//scriptlet("abp-hide-if-has-and-matches-style", "d[id^=\\"_\\"]", "div > s", "display: none")',
'example.org#%#//scriptlet("abp-hide-if-contains", "/.*/", ".p", "a[href^=\\"/ad__c?\\"]")',
];
assert.deepEqual(actual, expected);
});

QUnit.test('Test UBO to Adguard scriptlet converter', (assert) => {
Expand Down

0 comments on commit 0f94285

Please sign in to comment.