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

Fix 'json-prune' — obligatoryProps #345

Closed
AdamWr opened this issue Jul 31, 2023 · 0 comments
Closed

Fix 'json-prune' — obligatoryProps #345

AdamWr opened this issue Jul 31, 2023 · 0 comments

Comments

@AdamWr
Copy link
Member

AdamWr commented Jul 31, 2023

It seems that in some cases obligatoryProps does not work correctly if there is no * in the path.

Steps to reproduce:

  1. Add this rule:
example.org#%#//scriptlet('json-prune', 'whatever.qwerty advert', 'path.not.exist')
  1. Go to - https://example.org/
  2. Run in console:
const jsonObj = '{"advert":"hello","foo":{"bar":1}}';
const test = JSON.parse(jsonObj);
console.debug('test.advert:', test.advert);

advert should not be removed and test.advert should returns hello, because there is no path.not.exist in JSON object.

But, currently advert is removed and test.advert returns undefined.

Screenshot

image

Rule like this:

example.org#%#//scriptlet('json-prune', 'whatever.qwerty advert', '*.not.exist')

works correctly.

Screenshot

image

@adguard-bot adguard-bot assigned slavaleleka and unassigned maximtop Aug 10, 2023
adguard pushed a commit that referenced this issue Aug 10, 2023
Squashed commit of the following:

commit 38f0da2
Author: Slava Leleka <v.leleka@adguard.com>
Date:   Thu Aug 10 13:22:40 2023 +0300

    Update test description

commit 4c9356b
Author: Slava Leleka <v.leleka@adguard.com>
Date:   Thu Aug 10 13:22:08 2023 +0300

    Update test description

commit 15b3d7c
Merge: 0e3b35c 1b81a02
Author: Adam Wróblewski <adam@adguard.com>
Date:   Thu Aug 10 11:08:30 2023 +0200

    Merge branch 'master' into fix/AG-24527

commit 0e3b35c
Merge: 31d149d 975ad11
Author: Adam Wróblewski <adam@adguard.com>
Date:   Fri Aug 4 14:49:41 2023 +0200

    Merge branch 'master' into fix/AG-24527

commit 31d149d
Author: Adam Wróblewski <adam@adguard.com>
Date:   Thu Aug 3 16:24:50 2023 +0200

    Fix issue with stack and obligatoryProps in json-prune
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

4 participants