Skip to content

Commit

Permalink
feat(ipx): compatible with 0.7.x
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Jul 2, 2021
1 parent 695c616 commit 017c335
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
10 changes: 5 additions & 5 deletions src/runtime/providers/ipx.ts
Original file line number Diff line number Diff line change
@@ -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({
Expand All @@ -12,21 +12,21 @@ 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
}

const params = operationsGenerator(modifiers)

return {
url: joinURL(nuxtBase, baseURL, encodePath(src) + (params ? '?' + params : ''))
url: joinURL(nuxtBase, baseURL, params, encodePath(src))
}
}

Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 017c335

Please sign in to comment.