0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-04-01 02:41:39 -05:00

Reduced urlUtils dependency in ImageHandler

refs https://github.com/TryGhost/Toolbox/issues/523

- url-utils module is actively being stripped down from usages across codebase. The "urlUtils.STATIC_IMAGE_URL_PREFIX" and "store.staticFileURLPrefix" are the same values - the main difference is with the value coming from store we can make this module more generic for any store type (images, media, files, etc)
This commit is contained in:
Naz 2023-03-01 16:10:54 +08:00
parent 3119a5cc4c
commit 6c9e046b4b
No known key found for this signature in database

View file

@ -15,7 +15,7 @@ ImageHandler = {
const store = storage.getStorage('images');
const baseDirRegex = baseDir ? new RegExp('^' + baseDir + '/') : new RegExp('');
const imageFolderRegexes = _.map(urlUtils.STATIC_IMAGE_URL_PREFIX.split('/'), function (dir) {
const imageFolderRegexes = _.map(store.staticFileURLPrefix.split('/'), function (dir) {
return new RegExp('^' + dir + '/');
});
@ -36,7 +36,7 @@ ImageHandler = {
return Promise.all(files.map(function (image) {
return store.getUniqueFileName(image, image.targetDir).then(function (targetFilename) {
image.newPath = urlUtils.urlJoin('/', urlUtils.getSubdir(), urlUtils.STATIC_IMAGE_URL_PREFIX,
image.newPath = urlUtils.urlJoin('/', urlUtils.getSubdir(), store.staticFileURLPrefix,
path.relative(config.getContentPath('images'), targetFilename));
return image;