This commit is contained in:
Jan Prochazka
2021-01-23 07:24:46 +01:00
parent 451af5d09f
commit b9cb8c3a45
22 changed files with 127 additions and 129 deletions

View File

@@ -4,7 +4,7 @@ import _isString from 'lodash/isString';
export function compilePermissions(permissions: string[] | string) {
if (!permissions) return null;
if (_isString(permissions)) permissions = permissions.split(',');
return permissions.map((x) => new RegExp('^' + _escapeRegExp(x).replace(/\\\*/g, '.*') + '$'));
return permissions.map(x => new RegExp('^' + _escapeRegExp(x).replace(/\\\*/g, '.*') + '$'));
}
export function testPermission(tested: string, permissions: RegExp[]) {