Comparing version 5.11.2 to 5.11.3
@@ -0,1 +1,8 @@ | ||
## [5.11.3](https://github.com/casbin/node-casbin/compare/v5.11.2...v5.11.3) (2021-08-13) | ||
### Bug Fixes | ||
* add support for legacy array definition method ([#313](https://github.com/casbin/node-casbin/issues/313)) ([635eece](https://github.com/casbin/node-casbin/commit/635eece1bead0bb365b9ea50f325860d1df3abc6)) | ||
## [5.11.2](https://github.com/casbin/node-casbin/compare/v5.11.1...v5.11.2) (2021-08-13) | ||
@@ -2,0 +9,0 @@ |
@@ -43,2 +43,3 @@ "use strict"; | ||
if (!expression) { | ||
exp = util_1.bracketCompatible(exp); | ||
expression = asyncCompile ? expression_eval_1.compileAsync(exp) : expression_eval_1.compile(exp); | ||
@@ -45,0 +46,0 @@ this.matcherMap.set(matcherKey, expression); |
@@ -18,2 +18,3 @@ declare function escapeAssertion(s: string): string; | ||
declare function customIn(a: number | string, b: number | string): number; | ||
export { escapeAssertion, removeComments, arrayEquals, array2DEquals, arrayRemoveDuplicates, arrayToString, paramsToString, setEquals, readFile, writeFile, hasEval, replaceEval, getEvalValue, generatorRunSync, generatorRunAsync, deepCopy, customIn, }; | ||
declare function bracketCompatible(exp: string): string; | ||
export { escapeAssertion, removeComments, arrayEquals, array2DEquals, arrayRemoveDuplicates, arrayToString, paramsToString, setEquals, readFile, writeFile, hasEval, replaceEval, getEvalValue, generatorRunSync, generatorRunAsync, deepCopy, customIn, bracketCompatible, }; |
@@ -16,3 +16,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.customIn = exports.deepCopy = exports.generatorRunAsync = exports.generatorRunSync = exports.getEvalValue = exports.replaceEval = exports.hasEval = exports.writeFile = exports.readFile = exports.setEquals = exports.paramsToString = exports.arrayToString = exports.arrayRemoveDuplicates = exports.array2DEquals = exports.arrayEquals = exports.removeComments = exports.escapeAssertion = void 0; | ||
exports.bracketCompatible = exports.customIn = exports.deepCopy = exports.generatorRunAsync = exports.generatorRunSync = exports.getEvalValue = exports.replaceEval = exports.hasEval = exports.writeFile = exports.readFile = exports.setEquals = exports.paramsToString = exports.arrayToString = exports.arrayRemoveDuplicates = exports.array2DEquals = exports.arrayEquals = exports.removeComments = exports.escapeAssertion = void 0; | ||
const fs = require("fs"); | ||
@@ -182,1 +182,20 @@ // escapeAssertion escapes the dots in the assertion, | ||
exports.customIn = customIn; | ||
function bracketCompatible(exp) { | ||
// TODO: This function didn't support nested bracket. | ||
if (!(exp.includes(' in ') && exp.includes(' ('))) { | ||
return exp; | ||
} | ||
const re = / \([^)]*\)/g; | ||
const array = exp.split(''); | ||
let reResult; | ||
while ((reResult = re.exec(exp)) !== null) { | ||
if (!reResult[0].includes(',')) { | ||
continue; | ||
} | ||
array[reResult.index + 1] = '['; | ||
array[re.lastIndex - 1] = ']'; | ||
} | ||
exp = array.join(''); | ||
return exp; | ||
} | ||
exports.bracketCompatible = bracketCompatible; |
@@ -18,3 +18,3 @@ // Copyright 2018 The Casbin Authors. All Rights Reserved. | ||
import { DefaultRoleManager } from './rbac'; | ||
import { escapeAssertion, generateGFunction, getEvalValue, hasEval, replaceEval, generatorRunSync, generatorRunAsync, customIn, } from './util'; | ||
import { escapeAssertion, generateGFunction, getEvalValue, hasEval, replaceEval, generatorRunSync, generatorRunAsync, customIn, bracketCompatible, } from './util'; | ||
import { getLogger, logPrint } from './log'; | ||
@@ -41,2 +41,3 @@ /** | ||
if (!expression) { | ||
exp = bracketCompatible(exp); | ||
expression = asyncCompile ? compileAsync(exp) : compile(exp); | ||
@@ -43,0 +44,0 @@ this.matcherMap.set(matcherKey, expression); |
@@ -18,2 +18,3 @@ declare function escapeAssertion(s: string): string; | ||
declare function customIn(a: number | string, b: number | string): number; | ||
export { escapeAssertion, removeComments, arrayEquals, array2DEquals, arrayRemoveDuplicates, arrayToString, paramsToString, setEquals, readFile, writeFile, hasEval, replaceEval, getEvalValue, generatorRunSync, generatorRunAsync, deepCopy, customIn, }; | ||
declare function bracketCompatible(exp: string): string; | ||
export { escapeAssertion, removeComments, arrayEquals, array2DEquals, arrayRemoveDuplicates, arrayToString, paramsToString, setEquals, readFile, writeFile, hasEval, replaceEval, getEvalValue, generatorRunSync, generatorRunAsync, deepCopy, customIn, bracketCompatible, }; |
@@ -161,2 +161,20 @@ // Copyright 2017 The casbin Authors. All Rights Reserved. | ||
} | ||
export { escapeAssertion, removeComments, arrayEquals, array2DEquals, arrayRemoveDuplicates, arrayToString, paramsToString, setEquals, readFile, writeFile, hasEval, replaceEval, getEvalValue, generatorRunSync, generatorRunAsync, deepCopy, customIn, }; | ||
function bracketCompatible(exp) { | ||
// TODO: This function didn't support nested bracket. | ||
if (!(exp.includes(' in ') && exp.includes(' ('))) { | ||
return exp; | ||
} | ||
const re = / \([^)]*\)/g; | ||
const array = exp.split(''); | ||
let reResult; | ||
while ((reResult = re.exec(exp)) !== null) { | ||
if (!reResult[0].includes(',')) { | ||
continue; | ||
} | ||
array[reResult.index + 1] = '['; | ||
array[re.lastIndex - 1] = ']'; | ||
} | ||
exp = array.join(''); | ||
return exp; | ||
} | ||
export { escapeAssertion, removeComments, arrayEquals, array2DEquals, arrayRemoveDuplicates, arrayToString, paramsToString, setEquals, readFile, writeFile, hasEval, replaceEval, getEvalValue, generatorRunSync, generatorRunAsync, deepCopy, customIn, bracketCompatible, }; |
{ | ||
"name": "casbin", | ||
"version": "5.11.2", | ||
"version": "5.11.3", | ||
"description": "An authorization library that supports access control models like ACL, RBAC, ABAC in Node.JS", | ||
@@ -5,0 +5,0 @@ "main": "lib/cjs/index.js", |
529790
12648