fix(editor): Move projects and rbac files (no-changelog) (#9651)

This commit is contained in:
Csaba Tuncsik
2024-06-06 15:30:17 +02:00
committed by GitHub
parent 58cfd2fde8
commit ed963011c9
94 changed files with 172 additions and 212 deletions

View File

@@ -0,0 +1,28 @@
// Splits a project name into first name, last name, and email when it is in the format "First Last <email@domain.com>"
export const splitName = (
projectName: string,
): {
firstName: string;
lastName?: string;
email?: string;
} => {
const regex = /^(.+)?\s?<([^>]+)>$/;
const match = projectName.match(regex);
if (match) {
const [_, fullName, email] = match;
const nameParts = fullName?.trim().split(/\s+/);
const lastName = nameParts?.pop();
const firstName = nameParts?.join(' ');
return { firstName, lastName, email };
} else {
const nameParts = projectName.split(/\s+/) ?? [];
if (nameParts.length < 2) {
return { firstName: projectName };
} else {
const lastName = nameParts.pop();
const firstName = nameParts.join(' ');
return { firstName, lastName };
}
}
};