Skip to content

Commit

Permalink
fix(*): multiple require subrights
Browse files Browse the repository at this point in the history
has rights should not be escaped multiple times
otherwise it can not be verified anymore
  • Loading branch information
DanielSchuech authored and ds82 committed Jan 30, 2020
1 parent 826b3e6 commit cca7ba0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 7 additions & 0 deletions spec/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,5 +88,12 @@ describe('access.js', function() {

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

it('test #3: work with multiple required rights and subrights', () => {
const has = ['a.b'];
const needs = ['a.a', 'a.b'];
const result = uut.isAllowed(has, needs);
expect(result).toBe(true);
});
});
});
4 changes: 2 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ function checkOr(has, requires) {
var found = false;

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

0 comments on commit cca7ba0

Please sign in to comment.