Skip to content

Commit

Permalink
feat(*): allow - in name of rights
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielSchuech authored and ds82 committed Apr 29, 2021
1 parent cca7ba0 commit 73488ce
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions spec/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,16 @@ describe('access.js', function() {
expect(result).toBe(true);
});

it('test #2: is Allowed should return true for - in rights', () => {
const has = ['filebrowser.local.read'];

const needs = 'filebrowser.local.read.demo-test';

const result = uut.isAllowed(has, needs);

expect(result).toBe(true);
});

it('test #3: work with multiple required rights and subrights', () => {
const has = ['a.b'];
const needs = ['a.a', 'a.b'];
Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function checkOr(has, requires) {

has.forEach(function(right) {
right = escapeRegExp(right);
var regExp = new RegExp('^' + right + '(\\.[a-zA-Z0-9_\\.]*)*$');
var regExp = new RegExp('^' + right + '(\\.[a-zA-Z0-9_\\-\\.]*)*$');
requires.forEach(function(required) {
found = found || regExp.test(required);
});
Expand Down

0 comments on commit 73488ce

Please sign in to comment.