diff --git a/spec/index.spec.js b/spec/index.spec.js index 6284873..5dde53c 100644 --- a/spec/index.spec.js +++ b/spec/index.spec.js @@ -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']; diff --git a/src/index.js b/src/index.js index cfcb1bc..0389cf1 100644 --- a/src/index.js +++ b/src/index.js @@ -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); });