From 4e87ccb5ce9c5c9e91dfcf780f7985de0a46b3f9 Mon Sep 17 00:00:00 2001 From: hta218 Date: Tue, 30 Jul 2024 09:03:07 +0700 Subject: [PATCH] Update resize shopify image func --- packages/hydrogen/src/utils.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/hydrogen/src/utils.ts b/packages/hydrogen/src/utils.ts index c17d144c..ad207ec1 100644 --- a/packages/hydrogen/src/utils.ts +++ b/packages/hydrogen/src/utils.ts @@ -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 }