Skip to content

Commit a5cda7b

Browse files
authored
Fix named transformation with spaces (#224)
1 parent e4e73a1 commit a5cda7b

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

cloudinary-core/src/main/java/com/cloudinary/Transformation.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -675,10 +675,13 @@ public String generate(Map options) {
675675

676676
List transformations = ObjectUtils.asArray(options.get("transformation"));
677677
boolean allNamed = true;
678-
for (Object baseTransformation : transformations) {
678+
for ( int i =0; i < transformations.size(); i++ ){
679+
Object baseTransformation = transformations.get(i);
679680
if (baseTransformation instanceof Map) {
680681
allNamed = false;
681682
break;
683+
} else if (baseTransformation instanceof String){
684+
transformations.set(i, ((String) baseTransformation).replaceAll(" ", "%20"));
682685
}
683686
}
684687
String namedTransformation = null;

cloudinary-core/src/test/java/com/cloudinary/test/CloudinaryTest.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,14 @@ public void testTransformationArray() {
388388
assertEquals(DEFAULT_UPLOAD_PATH + "t_blip.blop/test", result);
389389
}
390390

391+
@Test
392+
public void testNamedTransformationWithSpaces() {
393+
// should support named transformations with spaces
394+
Transformation transformation = new Transformation().named("blip blop");
395+
String result = cloudinary.url().transformation(transformation).generate("test");
396+
assertEquals(DEFAULT_UPLOAD_PATH + "t_blip%20blop/test", result);
397+
}
398+
391399
@Test
392400
public void testBaseTransformations() {
393401
// should support base transformation

0 commit comments

Comments
 (0)