mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-01 05:50:35 +03:00
2e21618290
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.
26 lines
741 B
JavaScript
26 lines
741 B
JavaScript
var got = require('got'),
|
|
_ = require('lodash'),
|
|
validator = require('../data/validation').validator,
|
|
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) {
|
|
if (_.isEmpty(url) || !validator.isURL(url)) {
|
|
return Promise.reject(new common.errors.InternalServerError({
|
|
message: 'URL empty or invalid.',
|
|
code: 'URL_MISSING_INVALID',
|
|
context: url
|
|
}));
|
|
}
|
|
|
|
var mergedOptions = _.merge({}, defaultOptions, options);
|
|
|
|
return got(url, mergedOptions);
|
|
};
|