diff --git a/ghost/link-redirects/lib/LinkRedirectsService.js b/ghost/link-redirects/lib/LinkRedirectsService.js index d460208dae..f40ba699dc 100644 --- a/ghost/link-redirects/lib/LinkRedirectsService.js +++ b/ghost/link-redirects/lib/LinkRedirectsService.js @@ -96,6 +96,7 @@ class LinkRedirectsService { DomainEvents.dispatch(event); + res.setHeader('X-Robots-Tag', 'noindex, nofollow'); return res.redirect(link.to.href); } } diff --git a/ghost/link-redirects/test/LinkRedirectsService.test.js b/ghost/link-redirects/test/LinkRedirectsService.test.js index 19b9337235..412583b11d 100644 --- a/ghost/link-redirects/test/LinkRedirectsService.test.js +++ b/ghost/link-redirects/test/LinkRedirectsService.test.js @@ -91,11 +91,13 @@ describe('LinkRedirectsService', function () { originalUrl: '/a' }; const res = { - redirect: sinon.fake() + redirect: sinon.fake(), + setHeader: sinon.fake() }; await instance.handleRequest(req, res); assert.equal(res.redirect.callCount, 1); assert.equal(res.redirect.getCall(0).args[0], 'https://localhost:2368/b'); + assert(res.setHeader.calledWith('X-Robots-Tag', 'noindex, nofollow')); }); it('does not redirect if not found', async function () {