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 |
||
---|---|---|
.. | ||
functional | ||
integration | ||
unit | ||
utils | ||
.jshintrc |