From c447b5c02a48f7d958436d7d4a5eb194ab18940f Mon Sep 17 00:00:00 2001 From: Nitzan Jaitman Date: Mon, 5 Nov 2018 16:54:18 +0200 Subject: [PATCH] Clone configuration in `Url.clone()` --- cloudinary-core/src/main/java/com/cloudinary/Url.java | 2 +- .../src/test/java/com/cloudinary/test/CloudinaryTest.java | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/cloudinary-core/src/main/java/com/cloudinary/Url.java b/cloudinary-core/src/main/java/com/cloudinary/Url.java index 4421a6c8..34543dde 100644 --- a/cloudinary-core/src/main/java/com/cloudinary/Url.java +++ b/cloudinary-core/src/main/java/com/cloudinary/Url.java @@ -52,7 +52,7 @@ public Url(Cloudinary cloudinary) { public Url clone() { Url cloned = cloudinary.url(); - + cloned.config.update(config.asMap()); cloned.fallbackContent = this.fallbackContent; cloned.format = this.format; cloned.posterSource = this.posterSource; diff --git a/cloudinary-core/src/test/java/com/cloudinary/test/CloudinaryTest.java b/cloudinary-core/src/test/java/com/cloudinary/test/CloudinaryTest.java index a04f46bc..7e279576 100644 --- a/cloudinary-core/src/test/java/com/cloudinary/test/CloudinaryTest.java +++ b/cloudinary-core/src/test/java/com/cloudinary/test/CloudinaryTest.java @@ -3,6 +3,7 @@ import com.cloudinary.Cloudinary; import com.cloudinary.ResponsiveBreakpoint; import com.cloudinary.Transformation; +import com.cloudinary.Url; import com.cloudinary.transformation.*; import com.cloudinary.utils.ObjectUtils; import junitparams.JUnitParamsRunner; @@ -1159,5 +1160,10 @@ public static Map getUrlParameters(URI uri) throws UnsupportedEn return params; } - + @Test + public void testUrlCloneConfig(){ + // verify that secure (from url.config) is cloned as well: + Url url = cloudinary.url().cloudName("cloud").format("frmt").publicId("123").secure(true); + assertEquals("https://res.cloudinary.com/cloud/image/upload/123.frmt", url.clone().generate()); + } }