Repository: kaliber5/ember-responsive-image (ts)

Issue:
Cloudinary's image format parameter is wrong for JPEG
Should be `f_jpg` instead of `f_jpeg`

Pull request:
Fix JPEG URLs for Cloudinary provider
Fixes #389

Patch:
diff --git a/addon/helpers/responsive-image-cloudinary-provider.ts b/addon/helpers/responsive-image-cloudinary-provider.ts
index de7ec3d4..45e581ab 100644
--- a/addon/helpers/responsive-image-cloudinary-provider.ts
+++ b/addon/helpers/responsive-image-cloudinary-provider.ts
@@ -17,6 +17,10 @@ interface CloudinaryOptions {
 
 const URL_REGEX = /https?:/;
 
+const formatMap: Record<string, string> = {
+  jpeg: 'jpg',
+};
+
 export const provider = (
   image: string,
   service: ResponsiveImageService,
@@ -46,7 +50,7 @@ export const provider = (
     imageUrlFor(width: number, type: ImageType = 'jpeg'): string {
       let resizeParams = `w_${width},c_limit,q_${options.quality ?? 'auto'}`;
       if (deliveryType !== 'upload') {
-        resizeParams += `,f_${type}`;
+        resizeParams += `,f_${formatMap[type] ?? type}`;
       }
 
       const params = options.transformations


Test patch:
diff --git a/tests/integration/helpers/responsive-image-cloudinary-provider-test.ts b/tests/integration/helpers/responsive-image-cloudinary-provider-test.ts
index b220aa35..c19477dd 100644
--- a/tests/integration/helpers/responsive-image-cloudinary-provider-test.ts
+++ b/tests/integration/helpers/responsive-image-cloudinary-provider-test.ts
@@ -21,7 +21,7 @@ module(
       assert.deepEqual(data.imageTypes, ['png', 'jpeg', 'webp', 'avif']);
     });
 
-    test('it returns correct image URLs', async function (assert) {
+    test('it returns correct upload image URLs', async function (assert) {
       await render(
         hbs`{{dump (responsive-image-cloudinary-provider "samples/animals/three-dogs")}}`
       );
@@ -44,6 +44,29 @@ module(
       );
     });
 
+    test('it returns correct fetch image URLs', async function (assert) {
+      await render(
+        hbs`{{dump (responsive-image-cloudinary-provider "https://via.placeholder.com/150")}}`
+      );
+
+      const data = getData() as ProviderResult;
+
+      assert.equal(
+        data.imageUrlFor(100, 'jpeg'),
+        'https://res.cloudinary.com/kaliber5/image/fetch/w_100,c_limit,q_auto,f_jpg/https%3A%2F%2Fvia.placeholder.com%2F150'
+      );
+
+      assert.equal(
+        data.imageUrlFor(1000, 'jpeg'),
+        'https://res.cloudinary.com/kaliber5/image/fetch/w_1000,c_limit,q_auto,f_jpg/https%3A%2F%2Fvia.placeholder.com%2F150'
+      );
+
+      assert.equal(
+        data.imageUrlFor(100, 'webp'),
+        'https://res.cloudinary.com/kaliber5/image/fetch/w_100,c_limit,q_auto,f_webp/https%3A%2F%2Fvia.placeholder.com%2F150'
+      );
+    });
+
     test('it supports custom transformations', async function (assert) {
       await render(
         hbs`{{dump (responsive-image-cloudinary-provider "samples/animals/three-dogs" transformations="co_rgb:20a020,e_colorize:50")}}`