mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-06 22:40:14 -05:00
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:
parent
409377476d
commit
6c204b4c42
2 changed files with 4 additions and 1 deletions
|
@ -96,6 +96,7 @@ class LinkRedirectsService {
|
||||||
|
|
||||||
DomainEvents.dispatch(event);
|
DomainEvents.dispatch(event);
|
||||||
|
|
||||||
|
res.setHeader('X-Robots-Tag', 'noindex, nofollow');
|
||||||
return res.redirect(link.to.href);
|
return res.redirect(link.to.href);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,11 +91,13 @@ describe('LinkRedirectsService', function () {
|
||||||
originalUrl: '/a'
|
originalUrl: '/a'
|
||||||
};
|
};
|
||||||
const res = {
|
const res = {
|
||||||
redirect: sinon.fake()
|
redirect: sinon.fake(),
|
||||||
|
setHeader: sinon.fake()
|
||||||
};
|
};
|
||||||
await instance.handleRequest(req, res);
|
await instance.handleRequest(req, res);
|
||||||
assert.equal(res.redirect.callCount, 1);
|
assert.equal(res.redirect.callCount, 1);
|
||||||
assert.equal(res.redirect.getCall(0).args[0], 'https://localhost:2368/b');
|
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 () {
|
it('does not redirect if not found', async function () {
|
||||||
|
|
Loading…
Reference in a new issue