mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 18:41:14 +00:00
fix(editor): Move projects and rbac files (no-changelog) (#9651)
This commit is contained in:
28
packages/editor-ui/src/utils/projects.utils.ts
Normal file
28
packages/editor-ui/src/utils/projects.utils.ts
Normal 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 };
|
||||
}
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user