Skip to content

Commit

Permalink
Fix issue when a deleting a node from an empty Json
Browse files Browse the repository at this point in the history
  • Loading branch information
en-milie committed Nov 9, 2020
1 parent 9a91236 commit 5e8edf4
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/main/java/com/endava/cats/util/CatsUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -194,11 +194,14 @@ public FuzzingResult replaceField(String payload, String jsonPropertyForReplacem
}

public String deleteNode(String payload, String node) {
try {
return JsonPath.parse(payload).delete(this.sanitizeToJsonPath(node)).jsonString();
} catch (PathNotFoundException e) {
return payload;
if (StringUtils.isNotBlank(payload)) {
try {
return JsonPath.parse(payload).delete(this.sanitizeToJsonPath(node)).jsonString();
} catch (PathNotFoundException e) {
return payload;
}
}
return payload;
}

public FuzzingResult replaceField(String payload, String jsonPropertyForReplacement, FuzzingStrategy fuzzingStrategyToApply, boolean mergeFuzzing) {
Expand Down

0 comments on commit 5e8edf4

Please sign in to comment.