mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-17 23:44:39 -05:00
Removed www from support address email
refs https://github.com/TryGhost/Team/issues/397 - the logic for default support address domain was not removing `www`, causing address to be formed as `noreply@www.example.com` instead of `noreply@example.com` - removes `www` from the domain for support email address
This commit is contained in:
parent
ba142e714b
commit
799570fbd0
3 changed files with 37 additions and 3 deletions
|
@ -3,7 +3,7 @@ import MemberAvatar from '../common/MemberGravatar';
|
||||||
import ActionButton from '../common/ActionButton';
|
import ActionButton from '../common/ActionButton';
|
||||||
import CloseButton from '../common/CloseButton';
|
import CloseButton from '../common/CloseButton';
|
||||||
import Switch from '../common/Switch';
|
import Switch from '../common/Switch';
|
||||||
import {getMemberSubscription, getMemberTierName, getSiteNewsletters, getUpdatedOfferPrice, hasMultipleNewsletters, hasMultipleProductsFeature, hasOnlyFreePlan, isComplimentaryMember} from '../../utils/helpers';
|
import {getMemberSubscription, getMemberTierName, getSiteNewsletters, getSupportAddress, getUpdatedOfferPrice, hasMultipleNewsletters, hasMultipleProductsFeature, hasOnlyFreePlan, isComplimentaryMember} from '../../utils/helpers';
|
||||||
import {getDateString} from '../../utils/date-time';
|
import {getDateString} from '../../utils/date-time';
|
||||||
import {ReactComponent as LoaderIcon} from '../../images/icons/loader.svg';
|
import {ReactComponent as LoaderIcon} from '../../images/icons/loader.svg';
|
||||||
import {ReactComponent as OfferTagIcon} from '../../images/icons/offer-tag.svg';
|
import {ReactComponent as OfferTagIcon} from '../../images/icons/offer-tag.svg';
|
||||||
|
@ -545,7 +545,7 @@ export default class AccountHomePage extends React.Component {
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {member, site} = this.context;
|
const {member, site} = this.context;
|
||||||
const {members_support_address: supportAddress} = site;
|
const supportAddress = getSupportAddress({site});
|
||||||
if (!member) {
|
if (!member) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -588,6 +588,11 @@ export const getMemberName = ({member}) => {
|
||||||
|
|
||||||
export const getSupportAddress = ({site}) => {
|
export const getSupportAddress = ({site}) => {
|
||||||
const {members_support_address: supportAddress} = site || {};
|
const {members_support_address: supportAddress} = site || {};
|
||||||
|
if (supportAddress?.split('@')?.length > 1) {
|
||||||
|
const [recipient, domain] = supportAddress?.split('@');
|
||||||
|
const updatedDomain = domain?.replace(/^(www)\.(?=[^/]*\..{2,5})/, '') || '';
|
||||||
|
return `${recipient}@${updatedDomain}`;
|
||||||
|
}
|
||||||
return supportAddress || '';
|
return supportAddress || '';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import {getCurrencySymbol, getFreeProduct, getMemberName, getMemberSubscription, getPriceFromSubscription, getPriceIdFromPageQuery, hasMultipleProducts, isActiveOffer, isInviteOnlySite, isPaidMember, isSameCurrency} from './helpers';
|
import {getCurrencySymbol, getFreeProduct, getMemberName, getMemberSubscription, getPriceFromSubscription, getPriceIdFromPageQuery, getSupportAddress, hasMultipleProducts, isActiveOffer, isInviteOnlySite, isPaidMember, isSameCurrency} from './helpers';
|
||||||
import * as Fixtures from './fixtures-generator';
|
import * as Fixtures from './fixtures-generator';
|
||||||
import {site as FixturesSite, member as FixtureMember, offer as FixtureOffer} from '../utils/test-fixtures';
|
import {site as FixturesSite, member as FixtureMember, offer as FixtureOffer} from '../utils/test-fixtures';
|
||||||
import {isComplimentaryMember} from '../utils/helpers';
|
import {isComplimentaryMember} from '../utils/helpers';
|
||||||
|
@ -186,6 +186,35 @@ describe('Helpers - ', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('getSupportAddress -', () => {
|
||||||
|
test('returns expected support address for non sub domain', () => {
|
||||||
|
let site = {
|
||||||
|
members_support_address: 'jamie@example.com'
|
||||||
|
};
|
||||||
|
const supportAddress = getSupportAddress({site});
|
||||||
|
|
||||||
|
expect(supportAddress).toBe('jamie@example.com');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('returns expected support address for non www sub domain', () => {
|
||||||
|
let site = {
|
||||||
|
members_support_address: 'jamie@blog.example.com'
|
||||||
|
};
|
||||||
|
const supportAddress = getSupportAddress({site});
|
||||||
|
|
||||||
|
expect(supportAddress).toBe('jamie@blog.example.com');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('returns expected support address for www domain', () => {
|
||||||
|
let site = {
|
||||||
|
members_support_address: 'jamie@www.example.com'
|
||||||
|
};
|
||||||
|
const supportAddress = getSupportAddress({site});
|
||||||
|
|
||||||
|
expect(supportAddress).toBe('jamie@example.com');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('getPriceIdFromPageQuery - ', () => {
|
describe('getPriceIdFromPageQuery - ', () => {
|
||||||
test('can correctly fetch price id from page query ', () => {
|
test('can correctly fetch price id from page query ', () => {
|
||||||
const mockPriceIdFn = getPriceIdFromPageQuery;
|
const mockPriceIdFn = getPriceIdFromPageQuery;
|
||||||
|
|
Loading…
Add table
Reference in a new issue