Skip to content

Commit 0f94285

Browse files
author
Oleg Labudko
committed
Merge pull request in ADGUARD-FILTERS/compiler from bug_fixes to master
* 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
2 parents ffe765d + 48b9cb8 commit 0f94285

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "adguard-filters-compiler",
3-
"version": "1.0.42",
3+
"version": "1.0.43",
44
"description": "Adguard filters compiler",
55
"homepage": "http://adguard.com",
66
"dependencies": {

src/main/converter.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,14 +131,15 @@ module.exports = (() => {
131131
}
132132

133133
// Convert UBO and ABP scriptlets to AdGuard scriptlets
134-
if (!rule.startsWith('!') && !rule.startsWith('#') && (scriptlets.isUboScriptletRule(rule) || scriptlets.isAbpSnippetRule(rule))) {
134+
if (!rule.startsWith(RuleMasks.MASK_COMMENT) && (scriptlets.isUboScriptletRule(rule) || scriptlets.isAbpSnippetRule(rule))) {
135135
const convertedRule = scriptlets.convertScriptletToAdg(rule);
136136
if (!convertedRule) {
137137
logger.error(`Unable to convert scriptlet to Adguard syntax: "${rule}" `);
138138
rule = `! Inconvertible scriptlet: ${rule}`;
139139
} else {
140140
logger.log(`Rule "${rule}" converted to: ${convertedRule}`);
141-
rule = convertedRule;
141+
result.push(...convertedRule);
142+
continue;
142143
}
143144
}
144145

src/test/test-converter.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,13 @@ QUnit.test('Test scriptlets lib converter', (assert) => {
178178
actual = scriptlets.convertScriptletToAdg('test.com#$#abort-on-property-read adsShown');
179179
expected = 'test.com#%#//scriptlet("abp-abort-on-property-read", "adsShown")';
180180
assert.equal(actual, expected);
181+
182+
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?"]\'');
183+
expected = [
184+
'example.org#%#//scriptlet("abp-hide-if-has-and-matches-style", "d[id^=\\"_\\"]", "div > s", "display: none")',
185+
'example.org#%#//scriptlet("abp-hide-if-contains", "/.*/", ".p", "a[href^=\\"/ad__c?\\"]")',
186+
];
187+
assert.deepEqual(actual, expected);
181188
});
182189

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

0 commit comments

Comments
 (0)