Skip to content

Commit

Permalink
fix : undefined trim error
Browse files Browse the repository at this point in the history
  • Loading branch information
hovelopin committed Nov 23, 2023
1 parent a67bb90 commit cd67383
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion react-multi-email/ReactMultiEmail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ export function ReactMultiEmail(props: IReactMultiEmailProps) {

const arr = [...setArr];
do {
if (arr[0] === undefined) return;
const validateResult = isEmail('' + arr[0].trim());

if (typeof validateResult === 'boolean') {
Expand All @@ -112,7 +113,7 @@ export function ReactMultiEmail(props: IReactMultiEmailProps) {
const validateResultWithDisplayName = isEmail('' + arr[0].trim(), { allowDisplayName });
if (validateResultWithDisplayName) {
// Strip display name from email formatted as such "First Last <[email protected]>"
const email = stripDisplayName ? arr.shift()?.split("<")[1].split(">")[0] : arr.shift();
const email = stripDisplayName ? arr.shift()?.split('<')[1].split('>')[0] : arr.shift();
addEmails('' + email);
} else {
if (arr.length === 1) {
Expand Down

0 comments on commit cd67383

Please sign in to comment.