diff --git a/ghost/portal/src/utils/helpers.js b/ghost/portal/src/utils/helpers.js index d99af91c03..83dbbe1d22 100644 --- a/ghost/portal/src/utils/helpers.js +++ b/ghost/portal/src/utils/helpers.js @@ -588,6 +588,13 @@ export const getMemberName = ({member}) => { export const getSupportAddress = ({site}) => { const {members_support_address: supportAddress} = site || {}; + + if (supportAddress.indexOf('@') < 0) { + const siteDomain = getSiteDomain({site}); + const updatedDomain = siteDomain?.replace(/^(www)\.(?=[^/]*\..{2,5})/, '') || ''; + return `${supportAddress}@${updatedDomain}`; + } + if (supportAddress?.split('@')?.length > 1) { const [recipient, domain] = supportAddress?.split('@'); const updatedDomain = domain?.replace(/^(www)\.(?=[^/]*\..{2,5})/, '') || ''; diff --git a/ghost/portal/src/utils/helpers.test.js b/ghost/portal/src/utils/helpers.test.js index a2d7dc7014..84c33fa163 100644 --- a/ghost/portal/src/utils/helpers.test.js +++ b/ghost/portal/src/utils/helpers.test.js @@ -213,6 +213,16 @@ describe('Helpers - ', () => { expect(supportAddress).toBe('jamie@example.com'); }); + + test('returns expected support address for default noreply value', () => { + let site = { + members_support_address: 'noreply', + url: 'https://www.example.com' + }; + const supportAddress = getSupportAddress({site}); + + expect(supportAddress).toBe('noreply@example.com'); + }); }); describe('getPriceIdFromPageQuery - ', () => {