diff --git a/dpath/segments.py b/dpath/segments.py index c3c9846..08b02d0 100644 --- a/dpath/segments.py +++ b/dpath/segments.py @@ -188,6 +188,10 @@ def match(segments: Path, glob: Glob): match(segments, glob) -> bool """ + # Handle edge case where last segment of the glob is a wildcard and we want fnmatchcase to validate the path. + if len(segments) == len(glob) - 1 and glob.count("*") > 0 and glob.index("*") == len(glob) - 1: + segments = list(segments) + [""] + segments = tuple(segments) glob = tuple(glob) diff --git a/tests/test_broken_afilter.py b/tests/test_broken_afilter.py index 683c727..1afca6f 100644 --- a/tests/test_broken_afilter.py +++ b/tests/test_broken_afilter.py @@ -52,7 +52,6 @@ def filter(x): ], } - results = [[x[0], x[1]] for x in dpath.search(a, 'actions/*', yielded=True)] results = [[x[0], x[1]] for x in dpath.search(a, 'actions/*', afilter=filter, yielded=True)] assert len(results) == 1 assert results[0][1]['type'] == 'correct'