Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions src/util/builtinOperators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,11 +224,9 @@ function keyMatch4(key1: string, key2: string): boolean {
});

for (const value of m.values()) {
if (value.length > 1) {
for (let i = 1; i < values.length; i++) {
if (values[i] !== values[0]) {
return false;
}
for (let i = 1; i < value.length; i++) {
if (value[i] !== value[0]) {
return false;
}
}
}
Expand Down
7 changes: 7 additions & 0 deletions test/util.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,13 @@ test('test keyMatch4Func', () => {
expect(util.keyMatch4Func('/parent/123/child/456/book/123', '/parent/{id}/child/{id}/book/{id}')).toEqual(false);
expect(util.keyMatch4Func('/parent/123/child/456/book/', '/parent/{id}/child/{id}/book/{id}')).toEqual(false);
expect(util.keyMatch4Func('/parent/123/child/456', '/parent/{id}/child/{id}/book/{id}')).toEqual(false);

// A repeated token must not be compared with the values of other tokens.
expect(util.keyMatch4Func('/parent/123/child/123/book/456', '/parent/{id}/child/{id}/book/{book_id}')).toEqual(true);
expect(util.keyMatch4Func('/parent/123/child/456/book/789', '/parent/{id}/child/{id}/book/{book_id}')).toEqual(false);
expect(util.keyMatch4Func('/org/1/user/2/org/1', '/org/{org}/user/{user}/org/{org}')).toEqual(true);
expect(util.keyMatch4Func('/org/1/user/2/org/3', '/org/{org}/user/{user}/org/{org}')).toEqual(false);
expect(util.keyMatch4Func('/a/x/b/y/c/y', '/a/{p}/b/{q}/c/{q}')).toEqual(true);
});

test('test keyMatch5Func', () => {
Expand Down
Loading