Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve 'trusted-replace-fetch-response'/'trusted-replace-xhr-response' — add ability to replace all matched content #303

Closed
AdamWr opened this issue Apr 3, 2023 · 0 comments

Comments

@AdamWr
Copy link
Member

AdamWr commented Apr 3, 2023

It seems that currently only first occurrence is replaced.

Steps to reproduce:

  1. Add this rule:
example.org#%#//scriptlet('trusted-replace-fetch-response', '/domain/', 'TEST1234', '/')
  1. Go to - https://example.org/
  2. Run in console:
const page = await fetch('/');
const text = await page.text();
const count = (text.match(/TEST1234/g) || []).length;
console.log(count);

count "should" returns 3, but returns 1.

Screenshot

image

@adguard-bot adguard-bot assigned maximtop and unassigned zzebrum Apr 28, 2023
@slavaleleka slavaleleka added the enhancement Improvement of existent feature label May 16, 2023
@adguard-bot adguard-bot assigned slavaleleka and unassigned maximtop May 31, 2023
adguard pushed a commit that referenced this issue Jul 7, 2023
…r-response' — add ability to replace all matched content. #303

Squashed commit of the following:

commit ea24d90
Merge: 1d3046c 10e4c54
Author: Adam Wróblewski <[email protected]>
Date:   Fri Jul 7 13:16:11 2023 +0200

    Merge branch 'master' into fix/AG-21081

commit 1d3046c
Merge: 59be739 d6713c7
Author: Adam Wróblewski <[email protected]>
Date:   Fri Jul 7 13:06:30 2023 +0200

    Merge branch 'master' into fix/AG-21081

commit 59be739
Author: Slava Leleka <[email protected]>
Date:   Fri Jul 7 12:28:00 2023 +0300

    Update changelog

commit 71c74b5
Merge: e288834 c647f9a
Author: Adam Wróblewski <[email protected]>
Date:   Fri Jul 7 08:55:44 2023 +0200

    Merge branch 'master' into fix/AG-21081

commit e288834
Merge: 18cfaca 2b35bd5
Author: Adam Wróblewski <[email protected]>
Date:   Thu Jun 29 14:19:55 2023 +0200

    Merge branch 'master' into fix/AG-21081

commit 18cfaca
Merge: 9395fa5 c6b7eda
Author: Adam Wróblewski <[email protected]>
Date:   Thu Jun 29 12:27:45 2023 +0200

    Merge branch 'master' into fix/AG-21081

commit 9395fa5
Author: Adam Wróblewski <[email protected]>
Date:   Thu Jun 29 10:23:20 2023 +0200

    Rename hasRegExpFlags to getRegExpFlags
    Update JSDoc
    Get rid of unnecessary flagsStr

commit 8f02390
Author: Adam Wróblewski <[email protected]>
Date:   Wed Jun 28 11:03:32 2023 +0200

    Do not return boolean in hasRegExpFlags
    Use isValidRegExpFlag instead of match method

commit b26f700
Author: Adam Wróblewski <[email protected]>
Date:   Tue Jun 27 15:14:17 2023 +0200

    Update JSDoc
    Check only valid flags

commit 23c7526
Merge: c5114da 97e7764
Author: Adam Wróblewski <[email protected]>
Date:   Tue Jun 27 11:52:50 2023 +0200

    Merge branch 'master' into fix/AG-21081

commit c5114da
Author: Adam Wróblewski <[email protected]>
Date:   Tue Jun 27 10:08:04 2023 +0200

    Add JSDoc comments
    Update toRegExp description
    Rename regExpHasFlags to hasRegExpFlags
    Refactor the statement

commit 0e46a06
Author: Slava Leleka <[email protected]>
Date:   Mon Jun 26 11:53:50 2023 +0300

    Update changelog

commit 2364099
Author: Adam Wróblewski <[email protected]>
Date:   Mon Jun 26 09:09:09 2023 +0200

    Add ability to use regexp flags in toRegExp helper
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants