Skip to content

Commit

Permalink
Update resize shopify image func
Browse files Browse the repository at this point in the history
  • Loading branch information
hta218 committed Jul 30, 2024
1 parent 969e696 commit 4e87ccb
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions packages/hydrogen/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,8 @@ export function resizeShopifyImage(imageURL: string, size: string): string {
if (size === 'original') {
return imageURL
}
let matches = imageURL.match(/(.*\/[\w-_.]+)\.(\w{2,4})/)
// @ts-ignore
return `${matches[1]}_${size}.${matches[2]}`
let [, path, ext] = imageURL.match(/(.*\/[\w-_.]+)\.(\w{2,4})/)
return `${path}_${size}.${ext}`
} catch (e) {
return imageURL
}
Expand Down

0 comments on commit 4e87ccb

Please sign in to comment.