From 0e122dcc2f890963a6a6d856526e4fe9e25fd923 Mon Sep 17 00:00:00 2001 From: janrywang Date: Sun, 24 Apr 2022 15:39:05 +0800 Subject: [PATCH] fix(path): fix range all match is not expect --- packages/path/src/__tests__/match.spec.ts | 6 ++++++ packages/path/src/matcher.ts | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/path/src/__tests__/match.spec.ts b/packages/path/src/__tests__/match.spec.ts index 41ce2f70c65..e4bf15ea638 100644 --- a/packages/path/src/__tests__/match.spec.ts +++ b/packages/path/src/__tests__/match.spec.ts @@ -202,6 +202,12 @@ test('group match with destructor', () => { ).toEqual(true) }) +test('all range match', () => { + expect( + Path.parse('array.*[:].*[:].*[:].bb').match('array.0.0.0.aa') + ).toBeFalsy() +}) + match({ '*': [[], ['aa'], ['aa', 'bb', 'cc'], ['aa', 'dd', 'gg']], '*.a.b': [ diff --git a/packages/path/src/matcher.ts b/packages/path/src/matcher.ts index e12bc0c240d..d33e7f8ced2 100644 --- a/packages/path/src/matcher.ts +++ b/packages/path/src/matcher.ts @@ -178,7 +178,8 @@ export class Matcher { if (node.end) { return current <= Number(node.end.value) } else { - return true + this.wildcards = this.stack.slice() as WildcardOperatorNode[] + return this.next(node, pos) } } }