Fixed incorrect newsletter ref for internal links

refs TryGhost/Team#2755

Previous change for outbound tagging had incorrectly changed the internal links ref for newsletter to include domain. This change fixes it back to use newsletter name for internal links.
This commit is contained in:
Rishabh 2023-03-17 20:55:43 +05:30
parent 92fc5bdf70
commit 3d68cd4544
2 changed files with 4 additions and 4 deletions

View File

@ -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
*/

View File

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