mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-02 08:13:34 +03:00
a45a91c906
refs #8868 * 📐 Use request util in image-size - swapped the usage of `got` for requests with the request util * 💄 Use catch predicates - Uses catch predicates instead of conditionals in `getImageSizeFromUrl` - Return `NotFoundError` if applicable in `getImageSizeFromFilePath` as the caller function `cachedImageSizeFromUrl` is differentiating those between this error and others. * 🐛 Fixed ImageObject URL & simplify no protocol URL logic - Using `ImageObject` as a global var resulted in having the `url` property being the same for all requests coming in. - The logic that checked for an existing protocol (e. g. gravatar URLs) was overly complicated. Refactored it to be more simple. - Passing the correct value to `fetchDimensionsFromBuffer` as the population of `imageObject.url` happens there. These are used in our structured data and need to be full URLs (in case of locally stored files) or the original URL (in case of URLs missing the protocol) - Added two more debug logs in `getCachedImageSizeFromUrl` so it's logged when an image is added to the cache even tho it was returned as error. * 👀 Differentiate error codes between request and storage * 🔥 Remove not needed `Promise.resolve()` We're always resolving the result in `getCachedImageSizeFromUrl`, so there's no need to return the values with a `Promise.resolve()`. The caller fn uses waits for the Promises to be fulfilled. * ☂️ Wrap already rejected predicate errors in catch all * Use errorDetails instead of context * ☂️ Support /assets/ image paths - adds a guard that checks the image URL for `/assets/` in the beginning and passes a completed URL to the request util to try and fetch the image size - adds tests |
||
---|---|---|
.. | ||
adapters | ||
api | ||
auth | ||
config | ||
controllers/frontend | ||
data/importer | ||
metadata | ||
middleware | ||
models/base | ||
models_plugins | ||
server_helpers | ||
settings | ||
sitemap | ||
themes | ||
utils | ||
admin_spec.js | ||
api_utils_spec.js | ||
apps_filters_spec.js | ||
apps_spec.js | ||
errors_spec.js | ||
exporter_spec.js | ||
filters_spec.js | ||
ghost_sdk_spec.js | ||
migration_fixture_utils_spec.js | ||
migration_spec.js | ||
permissions_spec.js | ||
rss_spec.js | ||
server_helpers_index_spec.js | ||
server_helpers_template_spec.js | ||
server_utils_spec.js | ||
slack_spec.js | ||
social-urls_spec.js | ||
utils_pipeline_spec.js | ||
validation_spec.js | ||
xmlrpc_spec.js |