Skip to content

Commit

Permalink
fix: for provider 'directus' deduplicate "transforms" modifier
Browse files Browse the repository at this point in the history
  • Loading branch information
hartmut-co-uk committed Jun 9, 2023
1 parent 57d535e commit 7ad61e9
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/runtime/providers/directus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ export const operationsGenerator = createOperationsGenerator({

export const getImage: ProviderGetImage = (src, { modifiers = {}, baseURL } = {}) => {
// Separating the transforms from the rest of the modifiers
const transforms = modifiers.transforms
let transforms = modifiers.transforms
if (transforms && transforms.length > 0) {
// de-duplicate (can get multiplied when haveing >1 densities configured)
transforms = transforms.filter((value, index) => transforms.indexOf(value) === index)
// We stringify and encode in URL the list of lists, then apply it back to the modifiers
modifiers.transforms = new URLSearchParams(JSON.stringify(transforms)).toString().replace(/=+$/, '') as unknown as (string | number)[][]
}
Expand Down

0 comments on commit 7ad61e9

Please sign in to comment.