Skip to content

Commit

Permalink
Merge branch 'master' into fix/AG-20196
Browse files Browse the repository at this point in the history
  • Loading branch information
slavaleleka committed May 15, 2023
2 parents eb1d72a + 898998d commit 35074e5
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 16 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/scriptlets",
"version": "1.9.11",
"version": "1.9.12",
"description": "AdGuard's JavaScript library of Scriptlets and Redirect resources",
"scripts": {
"build": "babel-node bundler.js",
Expand Down
14 changes: 1 addition & 13 deletions src/helpers/log-message.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
export const logMessage = (source, message, forced = false, convertMessageToString = true) => {
const {
name,
ruleText,
verbose,
} = source;

Expand All @@ -31,16 +30,5 @@ export const logMessage = (source, message, forced = false, convertMessageToStri
return;
}

let messageStr = `${name}: ${message}`;

// Extract scriptlet part from rule text
if (ruleText) {
const RULE_MARKER = '#%#//scriptlet';
const markerIdx = ruleText.indexOf(RULE_MARKER);
if (markerIdx > -1) {
const ruleWithoutDomains = ruleText.slice(markerIdx, ruleText.length);
messageStr += `; cannot apply rule: ${ruleWithoutDomains}`;
}
}
nativeConsole(messageStr);
nativeConsole(`${name}: ${message}`);
};
3 changes: 1 addition & 2 deletions tests/helpers/log-message.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ module(name, { afterEach });
const RULE_TEXT = 'example.org#%#//scriptlet(\'set-cookie\', \'name\', \'value\')';
const SCRIPTLET_NAME = 'set-cookie';
const MESSAGE = 'arbitrary text message';
const MESSAGE_EXTENSION = '; cannot apply rule: #%#//scriptlet(\'set-cookie\', \'name\', \'value\')';

test('Logs message conditionally', async (assert) => {
// eslint-disable-next-line no-console
Expand All @@ -26,7 +25,7 @@ test('Logs message conditionally', async (assert) => {
}
assert.strictEqual(
input,
`${SCRIPTLET_NAME}: ${MESSAGE}${MESSAGE_EXTENSION}`,
`${SCRIPTLET_NAME}: ${MESSAGE}`,
'message logged correctly',
);
};
Expand Down

0 comments on commit 35074e5

Please sign in to comment.