smtp/address: use `if`/`else` instead of ternary

This commit is contained in:
Zack Schuster 2022-09-27 10:04:05 -07:00
parent dabdbbd5eb
commit 19fd8338f5
3 changed files with 22 additions and 17 deletions

View File

@ -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

View File

@ -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;