mirror of https://github.com/eleith/emailjs.git
smtp/address: use `if`/`else` instead of ternary
This commit is contained in:
parent
dabdbbd5eb
commit
19fd8338f5
11
email.js
11
email.js
|
@ -143,8 +143,8 @@ function convertAddressTokens(tokens) {
|
|||
if (addresses.length === 0) {
|
||||
for (let i = texts.length - 1; i >= 0; i--) {
|
||||
const text = texts[i];
|
||||
texts[i] = text
|
||||
? text
|
||||
if ((text === null || text === void 0 ? void 0 : text.length) > 0) {
|
||||
texts[i] = text
|
||||
.replace(/\s*\b[^@\s]+@[^@\s]+\b\s*/, (address) => {
|
||||
if (addresses.length === 0) {
|
||||
addresses = [address.trim()];
|
||||
|
@ -154,8 +154,11 @@ function convertAddressTokens(tokens) {
|
|||
return address;
|
||||
}
|
||||
})
|
||||
.trim()
|
||||
: '';
|
||||
.trim();
|
||||
}
|
||||
else {
|
||||
texts[i] = '';
|
||||
}
|
||||
if (addresses.length > 0) {
|
||||
break;
|
||||
}
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -147,18 +147,20 @@ function convertAddressTokens(tokens: AddressToken[]) {
|
|||
if (addresses.length === 0) {
|
||||
for (let i = texts.length - 1; i >= 0; i--) {
|
||||
const text = texts[i];
|
||||
texts[i] = text
|
||||
? text
|
||||
.replace(/\s*\b[^@\s]+@[^@\s]+\b\s*/, (address: string) => {
|
||||
if (addresses.length === 0) {
|
||||
addresses = [address.trim()];
|
||||
return ' ';
|
||||
} else {
|
||||
return address;
|
||||
}
|
||||
})
|
||||
.trim()
|
||||
: '';
|
||||
if (text?.length > 0) {
|
||||
texts[i] = text
|
||||
.replace(/\s*\b[^@\s]+@[^@\s]+\b\s*/, (address: string) => {
|
||||
if (addresses.length === 0) {
|
||||
addresses = [address.trim()];
|
||||
return ' ';
|
||||
} else {
|
||||
return address;
|
||||
}
|
||||
})
|
||||
.trim();
|
||||
} else {
|
||||
texts[i] = '';
|
||||
}
|
||||
|
||||
if (addresses.length > 0) {
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue