0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-04-01 02:41:39 -05:00

Updated handling for default noreply support address

- with content api, site support address can have value of default `noreply`
- adds the default site domain for support address in case of missing domain
This commit is contained in:
Rishabh 2022-05-17 23:20:45 +05:30
parent 799570fbd0
commit 8108448f70
2 changed files with 17 additions and 0 deletions

View file

@ -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})/, '') || '';

View file

@ -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 - ', () => {