Skip to content

Commit 5a991fe

Browse files
committed
Update navigateToNode method to improve path validation
1 parent 3ce7c50 commit 5a991fe

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

SimpleAPI/src/main/java/com/bencodez/simpleapi/file/BungeeJsonFile.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,15 @@ private JsonObject navigateToNode(String path) {
5353
String[] parts = path.split("\\.");
5454
JsonObject current = conf;
5555

56-
for (int i = 0; i < parts.length - 1; i++) {
57-
if (current.has(parts[i]) && current.get(parts[i]).isJsonObject()) {
58-
current = current.getAsJsonObject(parts[i]);
56+
// Updated: Additional checks and informative logs
57+
for (String part : parts) {
58+
if (current.has(part) && current.get(part).isJsonObject()) {
59+
current = current.getAsJsonObject(part);
5960
} else {
60-
return null;
61+
//System.out.println("navigateToNode: Invalid path component: " + part);
62+
return null; // Return null when a part is invalid or not an object
6163
}
6264
}
63-
6465
return current;
6566
}
6667

0 commit comments

Comments
 (0)