SelfGrantableRoles: improve role name and alias parsing by accepting commas as delimiters as well
This commit is contained in:
parent
457d57fb8c
commit
b5c55f9510
1 changed files with 6 additions and 3 deletions
|
@ -53,7 +53,8 @@ export class SelfGrantableRoles extends Plugin {
|
||||||
const rolesToRemove: Set<Role> = new Set();
|
const rolesToRemove: Set<Role> = new Set();
|
||||||
|
|
||||||
// Match given role names with actual grantable roles
|
// Match given role names with actual grantable roles
|
||||||
for (const roleName of args.roleNames) {
|
const roleNames = args.roleNames.map(n => n.split(/[\s,]+/)).flat();
|
||||||
|
for (const roleName of roleNames) {
|
||||||
const normalized = roleName.toLowerCase();
|
const normalized = roleName.toLowerCase();
|
||||||
let matched = false;
|
let matched = false;
|
||||||
|
|
||||||
|
@ -126,7 +127,8 @@ export class SelfGrantableRoles extends Plugin {
|
||||||
const rolesToGrant: Set<Role> = new Set();
|
const rolesToGrant: Set<Role> = new Set();
|
||||||
|
|
||||||
// Match given role names with actual grantable roles
|
// Match given role names with actual grantable roles
|
||||||
for (const roleName of args.roleNames) {
|
const roleNames = args.roleNames.map(n => n.split(/[\s,]+/)).flat();
|
||||||
|
for (const roleName of roleNames) {
|
||||||
const normalized = roleName.toLowerCase();
|
const normalized = roleName.toLowerCase();
|
||||||
let matched = false;
|
let matched = false;
|
||||||
|
|
||||||
|
@ -198,7 +200,8 @@ export class SelfGrantableRoles extends Plugin {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const aliases = [role.name].concat(args.aliases || []);
|
const aliases = (args.aliases || []).map(n => n.split(/[\s,]+/)).flat();
|
||||||
|
aliases.unshift(role.name);
|
||||||
const normalizedAliases = aliases.map(a => a.toLowerCase());
|
const normalizedAliases = aliases.map(a => a.toLowerCase());
|
||||||
const uniqueAliases = Array.from(new Set(normalizedAliases).values());
|
const uniqueAliases = Array.from(new Set(normalizedAliases).values());
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue