Skip to content

Commit

Permalink
fix: don't allow undefined values to override defaults (#274)
Browse files Browse the repository at this point in the history
closes #273
  • Loading branch information
danielroe authored May 17, 2021
1 parent 7e06ea6 commit d2e65f9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
5 changes: 1 addition & 4 deletions src/runtime/image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@ export function createImage (globalOptions: CreateImageOptions, nuxtContext: any
const $img = function $img (input, modifiers = {}, options = {}) {
return getImage(input, {
...options,
modifiers: {
...options.modifiers,
...modifiers
}
modifiers: defu(modifiers, options.modifiers || {})
}).url
} as $Img

Expand Down
3 changes: 2 additions & 1 deletion src/runtime/providers/cloudinary.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { ProviderGetImage } from 'src'
import { joinURL, encodePath } from 'ufo'
import defu from 'defu'
import { createOperationsGenerator } from '~image'

const convertHextoRGBFormat = (value: string) => value.startsWith('#') ? value.replace('#', 'rgb_') : value
Expand Down Expand Up @@ -80,7 +81,7 @@ const defaultModifiers = {
}

export const getImage: ProviderGetImage = (src, { modifiers = {}, baseURL = '/' } = {}) => {
const mergeModifiers = { ...defaultModifiers, ...modifiers }
const mergeModifiers = defu(modifiers, defaultModifiers)
const operations = operationsGenerator(mergeModifiers as any)

const remoteFolderMapping = baseURL.match(/\/image\/upload\/(.*)/)
Expand Down

0 comments on commit d2e65f9

Please sign in to comment.