Added X-Robots-Tag header to redirect responses (#15700)

refs https://github.com/TryGhost/Team/issues/2072

We're still seeing some redirect URLs being indexed by Google.
This commit is contained in:
Fabien 'egg' O'Carroll 2022-10-27 10:07:36 +07:00 committed by GitHub
parent 409377476d
commit 6c204b4c42
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 1 deletions

View File

@ -96,6 +96,7 @@ class LinkRedirectsService {
DomainEvents.dispatch(event);
res.setHeader('X-Robots-Tag', 'noindex, nofollow');
return res.redirect(link.to.href);
}
}

View File

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