File tree Expand file tree Collapse file tree 2 files changed +44
-3
lines changed
main/java/com/cloudinary/utils
test/java/com/cloudinary/transformation Expand file tree Collapse file tree 2 files changed +44
-3
lines changed Original file line number Diff line number Diff line change @@ -277,9 +277,8 @@ public static String mergeToSingleUnderscore(String s) {
277277 */
278278 public static boolean isVariable (String s ) {
279279 if (s == null ||
280- s .length () < 3 ||
281- !s .startsWith ("$" ) ||
282- !Character .isLetter (s .charAt (1 ))) {
280+ s .length () < 2 ||
281+ !s .startsWith ("$" )) {
283282 return false ;
284283 }
285284
Original file line number Diff line number Diff line change 1+ package com .cloudinary .transformation ;
2+
3+ import com .cloudinary .Cloudinary ;
4+ import com .cloudinary .Transformation ;
5+ import org .junit .Before ;
6+ import org .junit .Rule ;
7+ import org .junit .Test ;
8+ import org .junit .rules .TestName ;
9+
10+ import static org .junit .Assert .assertEquals ;
11+
12+ public class VariableTest {
13+
14+ private Cloudinary cloudinary ;
15+
16+ @ Rule
17+ public TestName currentTest = new TestName ();
18+
19+ @ Before
20+ public void setUp () {
21+ System .out .println ("Running " + this .getClass ().getName () + "." + currentTest .getMethodName ());
22+ this .cloudinary = new Cloudinary ("cloudinary://a:b@test123?load_strategies=false" );
23+ }
24+
25+ @ Test
26+ public void testSingleCharacterVariable () {
27+ String url = cloudinary .url ().transformation (new Transformation ().variable ("$a" ,"100" ).chain ().height ("$a" )).generate ("sample.jpg" );
28+ assertEquals ("http://res.cloudinary.com/test123/image/upload/$a_100/h_$a/sample.jpg" , url );
29+ }
30+
31+ @ Test
32+ public void testDollarOnlyAsVariable () {
33+ String url = cloudinary .url ().transformation (new Transformation ().variable ("$" ,"100" ).chain ().height ("$" )).generate ("sample.jpg" );
34+ assertEquals ("http://res.cloudinary.com/test123/image/upload/h_$/sample.jpg" , url );
35+ }
36+
37+ @ Test
38+ public void testMultipleCharactersVariable () {
39+ String url = cloudinary .url ().transformation (new Transformation ().variable ("$a45" ,"100" ).chain ().height ("$a45" )).generate ("sample.jpg" );
40+ assertEquals ("http://res.cloudinary.com/test123/image/upload/$a45_100/h_$a45/sample.jpg" , url );
41+ }
42+ }
You can’t perform that action at this time.
0 commit comments