From 5402c4d9bafcfd71509c9984f8a1215e62b6118b Mon Sep 17 00:00:00 2001 From: Lukas Krecan Date: Wed, 21 Feb 2024 19:29:22 +0100 Subject: [PATCH] Optimize path comparison --- .../net/javacrumbs/jsonunit/core/internal/PathMatcher.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/json-unit-core/src/main/java/net/javacrumbs/jsonunit/core/internal/PathMatcher.java b/json-unit-core/src/main/java/net/javacrumbs/jsonunit/core/internal/PathMatcher.java index e9a1537f..ef8024a1 100644 --- a/json-unit-core/src/main/java/net/javacrumbs/jsonunit/core/internal/PathMatcher.java +++ b/json-unit-core/src/main/java/net/javacrumbs/jsonunit/core/internal/PathMatcher.java @@ -57,8 +57,8 @@ private static class SimplePathMatcher extends PathMatcher { @Override boolean matches(String pathToMatch) { return path.equals(pathToMatch) - || (path.startsWith("$.") && path.substring(2).equals(pathToMatch)) - || (path.startsWith("$") && path.substring(1).equals(pathToMatch)); + || ((path.startsWith("$.") || path.startsWith("$[")) + && path.substring(2).equals(pathToMatch)); } }