Skip to content

Commit

Permalink
AG-25278 allow removeparam service to modify urls of POST requests
Browse files Browse the repository at this point in the history
Merge in ADGUARD-FILTERS/tsurlfilter from fix/AG-25278 to release/v2.2

Squashed commit of the following:

commit 4057d30
Merge: 0e626a0 34c7678
Author: Stanislav A <[email protected]>
Date:   Wed Sep 27 20:47:25 2023 +0300

    Merge branch 'release/v2.2' into fix/AG-25278

commit 0e626a0
Author: Stanislav A <[email protected]>
Date:   Wed Sep 20 14:39:54 2023 +0300

    remove todo

commit 4be108b
Author: Stanislav A <[email protected]>
Date:   Tue Sep 19 19:23:42 2023 +0300

    fix typo

commit bfcd430
Author: Stanislav A <[email protected]>
Date:   Tue Sep 19 19:12:11 2023 +0300

    add todo

commit 1ed8092
Author: Stanislav A <[email protected]>
Date:   Tue Sep 19 19:11:09 2023 +0300

    update changelog

commit 311580d
Author: Stanislav A <[email protected]>
Date:   Tue Sep 19 19:10:10 2023 +0300

    allow removeparamservice to modify urls of POST requests
  • Loading branch information
stanislav-atr authored and zhelvis committed Nov 16, 2023
1 parent af27954 commit 7d9b386
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
5 changes: 5 additions & 0 deletions packages/tswebextension/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
<!-- TODO: manually add compare links for version to the end of the file -->
<!-- e.g. [0.1.2]: https://github.com/AdguardTeam/tsurlfilter/compare/tswebextension-v0.1.1...tswebextension-v0.1.2 -->

## [Unreleased]

### Added
- Support for `POST` requests to `$removeparam` modifier [#99](https://github.com/AdguardTeam/tsurlfilter/issues/99).


## [0.4.5] - 2023-11-15

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class ParamsService {
this.filteringLog = filteringLog;
}

private static SupportedMethods = ['GET', 'OPTIONS', 'HEAD'];
private static SupportedMethods = ['GET', 'POST', 'OPTIONS', 'HEAD'];

/**
* Removes request params from url, stored in request context.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ describe('Params service', () => {
expect(purgedUrl).toBe(null);
});

it('removes get request params', () => {
it('removes GET request params', () => {
const purgedUrl = testUrlPurge(
'https://example.org?param=1',
'GET',
Expand All @@ -70,14 +70,17 @@ describe('Params service', () => {
);
});

it('ignores post request params', () => {
it('removes POST request params', () => {
const purgedUrl = testUrlPurge(
'https://example.org?param=1',
'POST',
['||example.org^$removeparam'],
);

expect(purgedUrl).toBe(null);
expect(purgedUrl).toBe('https://example.org');
expect(mockFilteringLog.publishEvent).toHaveBeenCalledWith(
expect.objectContaining({ type: FilteringEventType.RemoveParam }),
);
});

it('correctly processes allowlist rule', () => {
Expand Down

0 comments on commit 7d9b386

Please sign in to comment.