Display the correct domain in the message

[MAILPOET-1573]
This commit is contained in:
Pavel Dohnal
2019-01-22 14:34:10 +01:00
parent 4fb4e5a37a
commit 8cba3ba9d2
2 changed files with 7 additions and 6 deletions

View File

@@ -53,16 +53,17 @@ const badDomains = [
];
const SenderEmailAddressWarning = ({ emailAddress }) => {
const domain = emailAddress.split('@').pop().toLowerCase();
if (badDomains.indexOf(domain) > -1) {
const emailAddressDomain = emailAddress.split('@').pop().toLowerCase();
if (badDomains.indexOf(emailAddressDomain) > -1) {
const userHostDomain = window.location.hostname.replace('www.', '');
return (<React.Fragment>
<p className="sender_email_address_warning">{MailPoet.I18n.t('senderEmailAddressWarning1')}</p>
<p className="sender_email_address_warning">
{ReactStringReplace(
MailPoet.I18n.t('senderEmailAddressWarning2'),
/(%userDomain|%originalSender|<em>.*<\/em>)/,
/(%suggested|%originalSender|<em>.*<\/em>)/,
(match) => {
if (match === '%userDomain') return 'user domain'; // TODO replace with the real domain
if (match === '%suggested') return `info@${userHostDomain}`;
if (match === '%originalSender') return <em key="sender-email">{ emailAddress }</em>;
return <em key="reply-to">{match.replace(/<\/?em>/g, '')}</em>;
}