dbf43d792c
Closes the following issues. https://github.com/twentyhq/core-team-issues/issues/2368 https://github.com/twentyhq/core-team-issues/issues/2369 https://github.com/twentyhq/core-team-issues/issues/2374 https://github.com/twentyhq/core-team-issues/issues/2375
14 lines
329 B
TypeScript
14 lines
329 B
TypeScript
export function splitFullName(fullName: string): {
|
|
firstName: string;
|
|
lastName: string;
|
|
} {
|
|
const tokens = fullName.trim().split(/\s+/).filter(Boolean);
|
|
|
|
if (tokens.length === 0) {
|
|
return { firstName: '', lastName: '' };
|
|
}
|
|
|
|
const [firstName, ...rest] = tokens;
|
|
return { firstName, lastName: rest.join(' ') };
|
|
}
|