Merge branch 'master' into develop

isekai-main
Barış Soner Uşaklı 1 year ago
commit 9720bb4846

@ -55,7 +55,7 @@ Groups.removeEphemeralGroups = function (groups) {
return groups; return groups;
}; };
const isPrivilegeGroupRegex = /^cid:\d+:privileges:[\w\-:]+$/; const isPrivilegeGroupRegex = /^cid:(?:\d+|admin):privileges:[\w\-:]+$/;
Groups.isPrivilegeGroup = function (groupName) { Groups.isPrivilegeGroup = function (groupName) {
return isPrivilegeGroupRegex.test(groupName); return isPrivilegeGroupRegex.test(groupName);
}; };

@ -1404,4 +1404,20 @@ describe('Groups', () => {
assert(!groupData['cover:url']); assert(!groupData['cover:url']);
}); });
}); });
describe('isPrivilegeGroup', () => {
assert.strictEqual(Groups.isPrivilegeGroup('cid:1:privileges:topics:find'), true);
assert.strictEqual(Groups.isPrivilegeGroup('cid:1:privileges:groups:topics:find'), true);
assert.strictEqual(Groups.isPrivilegeGroup('cid:0:privileges:groups:search:users'), true);
assert.strictEqual(Groups.isPrivilegeGroup('cid:admin:privileges:admin:users'), true);
assert.strictEqual(Groups.isPrivilegeGroup('cid::privileges:admin:users'), false);
assert.strictEqual(Groups.isPrivilegeGroup('cid:string:privileges:admin:users'), false);
assert.strictEqual(Groups.isPrivilegeGroup('admin'), false);
assert.strictEqual(Groups.isPrivilegeGroup('registered-users'), false);
assert.strictEqual(Groups.isPrivilegeGroup(''), false);
assert.strictEqual(Groups.isPrivilegeGroup(null), false);
assert.strictEqual(Groups.isPrivilegeGroup(undefined), false);
assert.strictEqual(Groups.isPrivilegeGroup(false), false);
assert.strictEqual(Groups.isPrivilegeGroup(true), false);
});
}); });

Loading…
Cancel
Save