0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-20 22:42:53 -05:00

Changed path returned for uploads to absolute

refs #10438

- This change affects all /uploads/* and /images/* endpoints in Admin API
This commit is contained in:
Nazar Gargol 2019-01-31 15:02:33 +00:00
parent 24a2208625
commit a463a56971
4 changed files with 24 additions and 5 deletions

View file

@ -1,9 +1,10 @@
const debug = require('ghost-ignition').debug('api:v2:utils:serializers:output:upload');
const mapper = require('./utils/mapper');
module.exports = {
image(models, apiConfig, frame) {
debug('image');
return frame.response = models;
return frame.response = mapper.mapImage(models);
}
};

View file

@ -90,8 +90,13 @@ const mapIntegration = (model, frame) => {
return jsonModel;
};
const mapImage = (path) => {
return url.forImage(path);
};
module.exports.mapPost = mapPost;
module.exports.mapUser = mapUser;
module.exports.mapTag = mapTag;
module.exports.mapIntegration = mapIntegration;
module.exports.mapSettings = mapSettings;
module.exports.mapImage = mapImage;

View file

@ -90,7 +90,12 @@ const forSettings = (attrs) => {
return attrs;
};
const forImage = (path) => {
return urlService.utils.urlFor('image', {image: path}, true);
};
module.exports.forPost = forPost;
module.exports.forUser = forUser;
module.exports.forTag = forTag;
module.exports.forSettings = forSettings;
module.exports.forImage = forImage;

View file

@ -40,7 +40,9 @@ describe('Upload API', function () {
return done(err);
}
images.push(res.body);
res.body.should.match(new RegExp(`${config.get('url')}/content/images/\\d+/\\d+/ghost-logo.png`));
images.push(res.body.replace(config.get('url'), ''));
done();
});
});
@ -56,7 +58,9 @@ describe('Upload API', function () {
return done(err);
}
images.push(res.body);
res.body.should.match(new RegExp(`${config.get('url')}/content/images/\\d+/\\d+/ghosticon.jpg`));
images.push(res.body.replace(config.get('url'), ''));
done();
});
});
@ -72,7 +76,9 @@ describe('Upload API', function () {
return done(err);
}
images.push(res.body);
res.body.should.match(new RegExp(`${config.get('url')}/content/images/\\d+/\\d+/loadingcat.gif`));
images.push(res.body.replace(config.get('url'), ''));
done();
});
});
@ -88,7 +94,9 @@ describe('Upload API', function () {
return done(err);
}
images.push(res.body);
res.body.should.match(new RegExp(`${config.get('url')}/content/images/\\d+/\\d+/loadingcat_square.gif`));
images.push(res.body.replace(config.get('url'), ''));
done();
});
});