Skip to content

Commit

Permalink
refactor: extract host to a variable
Browse files Browse the repository at this point in the history
  • Loading branch information
fpdrozd committed Mar 27, 2023
1 parent a7f472b commit 87a8bb1
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions packages/api-client/src/api/serializers/product.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,11 +234,15 @@ const addHostToImage = (image, config: ApiConfig) => ({
...image,
attributes: {
...image.attributes,
styles: image.attributes?.styles ? image.attributes.styles.map((style) => ({
width: style.width,
height: style.height,
url: `${style.url.includes('http') ? '' : (config.assetsUrl || config.backendUrl)}${style.url}`
})) : []
styles: image.attributes?.styles ? image.attributes.styles.map((style) => {
const host = style.url.includes('http') ? '' : (config.assetsUrl || config.backendUrl);

return {
width: style.width,
height: style.height,
url: `${host}${style.url}`
};
}) : []
}
});

Expand Down

0 comments on commit 87a8bb1

Please sign in to comment.