mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-10 23:36:14 -05:00
Set Ghost user-agent header for got requests (#10424)
no-issue Currently the `user-agent` header is the for outgoing webhook calls is the `got` default: `User-Agent: got/8.3.2 (https://github.com/sindresorhus/got)`. This is pretty unfriendly to the receiver of the webhook who may wish to perform analytics on calling systems, implement security features based on calling system or take action based on different versions of a client. This PR sets the header to: `User-Agent: Ghost/2.12.0 (https://github.com/TryGhost/Ghost)` which is much more descriptive.
This commit is contained in:
parent
95880dddeb
commit
2e21618290
1 changed files with 11 additions and 2 deletions
|
@ -1,7 +1,14 @@
|
||||||
var got = require('got'),
|
var got = require('got'),
|
||||||
_ = require('lodash'),
|
_ = require('lodash'),
|
||||||
validator = require('../data/validation').validator,
|
validator = require('../data/validation').validator,
|
||||||
common = require('./common');
|
common = require('./common'),
|
||||||
|
ghostVersion = require('./ghost-version');
|
||||||
|
|
||||||
|
var defaultOptions = {
|
||||||
|
headers: {
|
||||||
|
'user-agent': 'Ghost/' + ghostVersion.original + ' (https://github.com/TryGhost/Ghost)'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
module.exports = function request(url, options) {
|
module.exports = function request(url, options) {
|
||||||
if (_.isEmpty(url) || !validator.isURL(url)) {
|
if (_.isEmpty(url) || !validator.isURL(url)) {
|
||||||
|
@ -12,5 +19,7 @@ module.exports = function request(url, options) {
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
return got(url, options);
|
var mergedOptions = _.merge({}, defaultOptions, options);
|
||||||
|
|
||||||
|
return got(url, mergedOptions);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue