diff --git a/ghost/member-attribution/lib/outbound-link-tagger.js b/ghost/member-attribution/lib/outbound-link-tagger.js index 53d6e14d22..0b3e34049a 100644 --- a/ghost/member-attribution/lib/outbound-link-tagger.js +++ b/ghost/member-attribution/lib/outbound-link-tagger.js @@ -66,7 +66,7 @@ class OutboundLinkTagger { const name = slugify(useNewsletter.get('name')); // If newsletter name ends with newsletter, don't add it again - const ref = name.endsWith('newsletter') ? `${domain}-${name}` : `${domain}-${name}-newsletter`; + const ref = name.endsWith('newsletter') ? name : `${name}-newsletter`; url.searchParams.append('ref', ref); } else { url.searchParams.append('ref', domain); @@ -92,7 +92,7 @@ class OutboundLinkTagger { * e.g. https://example.com/ -> example.com * e.g. https://example.ghost.io/ -> example.ghost.io * e.g. https://www.example.com/ -> example.com - * + * * @param {URL} url to extract domain from * @returns {string} just the domain, e.g. example.com or example.ghost.io, but not www.example.com */ diff --git a/ghost/member-attribution/test/outbound-link-tagger.test.js b/ghost/member-attribution/test/outbound-link-tagger.test.js index 09232d03ba..28765500a0 100644 --- a/ghost/member-attribution/test/outbound-link-tagger.test.js +++ b/ghost/member-attribution/test/outbound-link-tagger.test.js @@ -51,7 +51,7 @@ describe('OutboundLinkTagger', function () { const updatedUrl = await service.addToUrl(url, newsletter); - should(updatedUrl.toString()).equal('https://example.com/?ref=blog.com-used-newsletter-name-newsletter'); + should(updatedUrl.toString()).equal('https://example.com/?ref=used-newsletter-name-newsletter'); }); it('does not repeat newsletter at the end of the newsletter name', async function () { @@ -70,7 +70,7 @@ describe('OutboundLinkTagger', function () { }; const updatedUrl = await service.addToUrl(url, newsletter); - should(updatedUrl.toString()).equal('https://example.com/?ref=blog.com-weekly-newsletter'); + should(updatedUrl.toString()).equal('https://example.com/?ref=weekly-newsletter'); }); it('does not add ref to blocked domains', async function () {