mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-04 04:10:33 +03:00
ae741b1a18
refs #9178, refs #8988
With 7353c87d7f
we use Bluebird globally for Promises. Therefore, the request lib doesn't need to be wrapped in a bluebird Promise anymore.
This was originally done, so we can work with catch predicated in our image-size lib.
Updated the tests to proof, that the catch predicates work.
The tests fail, as soon as the Promise overwrite is commented out.
17 lines
481 B
JavaScript
17 lines
481 B
JavaScript
var got = require('got'),
|
|
_ = require('lodash'),
|
|
validator = require('../data/validation').validator,
|
|
common = require('./common');
|
|
|
|
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
|
|
}));
|
|
}
|
|
|
|
return got(url, options);
|
|
};
|