From 017c33514df00267dfa5f05429a573bca39ecc7a Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Fri, 2 Jul 2021 13:04:07 +0200 Subject: [PATCH] feat(ipx): compatible with 0.7.x --- package.json | 2 +- src/runtime/providers/ipx.ts | 10 +++++----- yarn.lock | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index af498ff53..622c62611 100755 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "fs-extra": "^10.0.0", "hasha": "^5.2.2", "image-meta": "^0.0.1", - "ipx": "^0.7.0", + "ipx": "^0.7.1", "is-https": "^4.0.0", "lru-cache": "^6.0.0", "node-fetch": "^2.6.1", diff --git a/src/runtime/providers/ipx.ts b/src/runtime/providers/ipx.ts index fd86adad2..5b0861490 100644 --- a/src/runtime/providers/ipx.ts +++ b/src/runtime/providers/ipx.ts @@ -1,5 +1,5 @@ import { ProviderGetImage } from 'src' -import { joinURL, encodeQueryItem, encodePath } from 'ufo' +import { joinURL, encodePath, encodeParam } from 'ufo' import { createOperationsGenerator } from '~image' const operationsGenerator = createOperationsGenerator({ @@ -12,13 +12,13 @@ const operationsGenerator = createOperationsGenerator({ quality: 'q', background: 'b' }, - joinWith: '&', - formatter: (key, val) => encodeQueryItem(key, val) + joinWith: ',', + formatter: (key, val) => encodeParam(key) + '_' + encodeParam(val) }) export const getImage: ProviderGetImage = (src, { modifiers = {}, baseURL = '/_ipx' } = {}, { nuxtContext: { base: nuxtBase = '/' } = {} }) => { if (modifiers.width && modifiers.height) { - modifiers.resize = `${modifiers.width}_${modifiers.height}` + modifiers.resize = `${modifiers.width}x${modifiers.height}` delete modifiers.width delete modifiers.height } @@ -26,7 +26,7 @@ export const getImage: ProviderGetImage = (src, { modifiers = {}, baseURL = '/_i const params = operationsGenerator(modifiers) return { - url: joinURL(nuxtBase, baseURL, encodePath(src) + (params ? '?' + params : '')) + url: joinURL(nuxtBase, baseURL, params, encodePath(src)) } } diff --git a/yarn.lock b/yarn.lock index 27f3aa3ac..010bd04ae 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6619,10 +6619,10 @@ ip@^1.1.5: resolved "https://registry.yarnpkg.com/ip/-/ip-1.1.5.tgz#bdded70114290828c0a039e72ef25f5aaec4354a" integrity sha1-vd7XARQpCCjAoDnnLvJfWq7ENUo= -ipx@^0.7.0: - version "0.7.0" - resolved "https://registry.yarnpkg.com/ipx/-/ipx-0.7.0.tgz#a8b93161d7bf1e179297104bd2a744624ed5960d" - integrity sha512-qR8bsoIgbCL+CAocXCVvQkWnvE4q8A2Tu1Ltx0HJPnTYpRG4HihOilGQVzuqxs0Vn89MVFOZ7JR4MFplFwoFZQ== +ipx@^0.7.1: + version "0.7.1" + resolved "https://registry.yarnpkg.com/ipx/-/ipx-0.7.1.tgz#58c5f2791cf616b3bed0d48f95e19455ccf581fb" + integrity sha512-Vwegvv14h5xL9AisCp3v8fh87Tbne40qZFTf2Z/kYs4p5i/eZznbk3slNgNoPyv7cAfVVnjFWTLwnxMkYf3rpw== dependencies: consola "^2.15.3" defu "^5.0.0"