This is an automated email from the ASF dual-hosted git repository.

hsluoyz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/casbin-node-casbin.git


The following commit(s) were added to refs/heads/master by this push:
     new 7dbadda  fix: compare both outer lengths in array2DEquals (#573)
7dbadda is described below

commit 7dbadda0f534765bb0b6b62db09dbe222b42f759
Author: Wu Shuwen <[email protected]>
AuthorDate: Sun Oct 25 22:01:13 2026 +0800

    fix: compare both outer lengths in array2DEquals (#573)
---
 src/util/util.ts  | 2 +-
 test/util.test.ts | 9 +++++++++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/util/util.ts b/src/util/util.ts
index 1646107..e148e77 100644
--- a/src/util/util.ts
+++ b/src/util/util.ts
@@ -80,7 +80,7 @@ function arrayEquals(a: string[] = [], b: string[] = []): 
boolean {
 // array2DEquals determines whether two 2-dimensional string arrays are 
identical.
 function array2DEquals(a: string[][] = [], b: string[][] = []): boolean {
   const aLen = a.length;
-  const bLen = a.length;
+  const bLen = b.length;
   if (aLen !== bLen) {
     return false;
   }
diff --git a/test/util.test.ts b/test/util.test.ts
index d5b9509..a7bf769 100644
--- a/test/util.test.ts
+++ b/test/util.test.ts
@@ -372,3 +372,12 @@ test('test escapeAssertion', () => {
   );
   expect(util.escapeAssertion(`r.obj == "a\\"/p.b" || p.obj == 
'/r.c'`)).toEqual(`r_obj == "a\\"/p.b" || p_obj == '/r.c'`);
 });
+
+test('array2DEquals compares both outer lengths', () => {
+  expect(util.array2DEquals([], [['alice', 'data1', 'read']])).toBe(false);
+  expect(util.array2DEquals([['alice']], [['alice'], ['bob']])).toBe(false);
+  expect(util.array2DEquals([['alice'], ['bob']], [['alice']])).toBe(false);
+  expect(util.array2DEquals([[]], [])).toBe(false);
+  expect(util.array2DEquals([], [[]])).toBe(false);
+  expect(util.array2DEquals([['alice']], [['alice']])).toBe(true);
+});


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to