'use strict';


module.exports = function checkRights(usernames, rights='', defaultValue=false) {
    if (! rights) return defaultValue;
    if (! usernames) return false;
    if (! Array.isArray(usernames)) usernames=[usernames];
    var alloweds=rights.split(/[ ,;\r\n]+/).filter(a => a);

    for (let username of usernames) {
        for (let allowed of alloweds) {
            if (username.endsWith(allowed)) return true;
        }
    }
    return false;
}
@@ -8,16 +8,122 @@
 rict';%0A%0A
+/**%0AChecks if one of the usernames is part of the rights list%0A A right may be a regular expression.%0A%0A */%0A%0A
 %0Amodule.
@@ -408,114 +408,449 @@
 let 
-username of usernames) %7B%0A        for (let allowed of alloweds) %7B%0A            if (username.endsWith(allowed
+allowed of alloweds) %7B%0A        let isRegExp=false;%0A        if (allowed.startsWith('/') && allowed.endsWith('/')) %7B%0A            isRegExp=true;%0A            var regexp=new RegExp(allowed.substring(1, allowed.length-1));%0A        %7D%0A%0A        for (let username of usernames) %7B%0A            if (isRegExp) %7B%0A                if (username.match(regexp)) return true;%0A            %7D else %7B%0A                if (username.toLowerCase()===allowed.toLowerCase(
 )) r
@@ -853,32 +853,46 @@
 )) return true;%0A
+            %7D%0A
         %7D%0A    %7D%0A

Update check rights to deal with regexp