Skip to content

Commit

Permalink
AG-7790 do not remove equality sign if value is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
maximtop committed May 6, 2021
1 parent be1a845 commit 8c508e4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
7 changes: 4 additions & 3 deletions Extension/lib/utils/url.js
Expand Up @@ -323,9 +323,10 @@
urlPieces[1] = urlPieces[1]
.split('&')
.filter(x => x)
.map(x => (x.includes('=') ? x : `${x}=`))
.filter(x => x && !x.match(regExp))
.map(x => (x.endsWith('=') ? x.substring(0, x.length - 1) : x))
.filter((x) => {
const test = x.includes('=') ? x : `${x}=`;
return !test.match(regExp);
})
.join('&');
}

Expand Down
5 changes: 4 additions & 1 deletion Extension/tests/url-filter/test-url-filter.js
Expand Up @@ -649,7 +649,10 @@ QUnit.module('$removeparam', () => {
QUnit.test('$removeparam does not remove redundant url parts', (assert) => {
const rule = new adguard.rules.UrlFilterRule('$removeparam=p1');

const url = 'https://l-stat.livejournal.net/js/??.comments.js?v=1619510974';
let url = 'https://l-stat.livejournal.net/js/??.comments.js?v=1619510974';
assert.equal(rule.getRemoveparam().apply(`${url}`), `${url}`);

url = 'http://example.com?stay=&stay2=2';
assert.equal(rule.getRemoveparam().apply(`${url}`), `${url}`);
});

Expand Down

0 comments on commit 8c508e4

Please sign in to comment.