Skip to content

Commit 1245aa0

Browse files
committed
fix(builtinoperators): fix function keyMatch3
fix #214 Signed-off-by: Andreas Bichinger <andreas.bichinger@gmail.com>
1 parent 5253b90 commit 1245aa0

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/util/builtinOperators.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ function keyMatch3(key1: string, key2: string): boolean {
8888
key2 = key2.replace(regexp, '$1[^/]+$2');
8989
}
9090

91-
return regexMatch(key1, key2);
91+
return regexMatch(key1, '^' + key2 + '$');
9292
}
9393

9494
// keyMatch3Func is the wrapper for keyMatch3.

test/util.test.ts

+2
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,15 @@ test('test keyMatch2Func', () => {
5454
expect(util.keyMatch2Func('/foo/baz', '/foo/:bar')).toEqual(true);
5555
expect(util.keyMatch2Func('/foo/baz/foo', '/foo/:bar/foo')).toEqual(true);
5656
expect(util.keyMatch2Func('/baz', '/foo')).toEqual(false);
57+
expect(util.keyMatch2Func('/foo/baz', '/foo')).toEqual(false);
5758
});
5859

5960
test('test keyMatch3Func', () => {
6061
expect(util.keyMatch3Func('/foo/bar', '/foo/*')).toEqual(true);
6162
expect(util.keyMatch3Func('/foo/baz', '/foo/{bar}')).toEqual(true);
6263
expect(util.keyMatch3Func('/foo/baz/foo', '/foo/{bar}/foo')).toEqual(true);
6364
expect(util.keyMatch3Func('/baz', '/foo')).toEqual(false);
65+
expect(util.keyMatch3Func('/foo/baz', '/foo')).toEqual(false);
6466
});
6567

6668
test('test keyMatch4Func', () => {

0 commit comments

Comments
 (0)