diff --git a/src/util/util.ts b/src/util/util.ts index 8b103e3..7c765a4 100644 --- a/src/util/util.ts +++ b/src/util/util.ts @@ -179,9 +179,9 @@ function deepCopy(obj: Array | any): any { function customIn(a: number | string, b: number | string): number { if ((b as any) instanceof Array) { - return (((b as any) as Array).includes(a) as unknown) as number; + return (b as any as Array).includes(a) as unknown as number; } - return ((a in (b as any)) as unknown) as number; + return (a in (b as any)) as unknown as number; } function bracketCompatible(exp: string): string { diff --git a/test/enforcer.test.ts b/test/enforcer.test.ts index a09c863..86642d3 100644 --- a/test/enforcer.test.ts +++ b/test/enforcer.test.ts @@ -597,9 +597,9 @@ test('test ABAC multiple eval()', async () => { ); const e = await newEnforcer(m, policy); - await testEnforce(e, 56, (98 as unknown) as string, 'read', true); - await testEnforce(e, 23, (67 as unknown) as string, 'read', false); - await testEnforce(e, 78, (34 as unknown) as string, 'read', false); + await testEnforce(e, 56, 98 as unknown as string, 'read', true); + await testEnforce(e, 23, 67 as unknown as string, 'read', false); + await testEnforce(e, 78, 34 as unknown as string, 'read', false); }); // https://github.com/casbin/node-casbin/issues/438 @@ -617,10 +617,10 @@ test('test ABAC single eval() with r. in unexpected places', async () => { ); const e = await newEnforcer(m, policy); - await testEnforce(e, { id: 3 }, ({ owner: { id: 3 } } as unknown) as string, 'read', true); - await testEnforce(e, {}, ({ owner: {} } as unknown) as string, 'read', false); - await testEnforce(e, { id: 3 }, ({ owner: {} } as unknown) as string, 'read', false); - await testEnforce(e, { id: 3 }, ({ owner: { id: 2 } } as unknown) as string, 'read', false); + await testEnforce(e, { id: 3 }, { owner: { id: 3 } } as unknown as string, 'read', true); + await testEnforce(e, {}, { owner: {} } as unknown as string, 'read', false); + await testEnforce(e, { id: 3 }, { owner: {} } as unknown as string, 'read', false); + await testEnforce(e, { id: 3 }, { owner: { id: 2 } } as unknown as string, 'read', false); }); test('TestEnforceSync', async () => {