@@ -186,7 +186,7 @@ String getEncodedValue(String value) {
186
186
String encodedValue ;
187
187
if (reservedExpansion ) {
188
188
// Reserved expansion allows pct-encoded triplets and characters in the reserved set.
189
- encodedValue = CharEscapers .escapeUriPath (value );
189
+ encodedValue = CharEscapers .escapeUriPathWithoutReserved (value );
190
190
} else {
191
191
encodedValue = CharEscapers .escapeUri (value );
192
192
}
@@ -339,26 +339,14 @@ public static String expand(String pathUri, Object parameters,
339
339
value = getListPropertyValue (varName , iterator , containsExplodeModifier , compositeOutput );
340
340
} else if (value .getClass ().isEnum ()) {
341
341
String name = FieldInfo .of ((Enum <?>) value ).getName ();
342
- if (name != null ) {
343
- if (compositeOutput .requiresVarAssignment ()) {
344
- value = String .format ("%s=%s" , varName , value );
345
- }
346
- value = CharEscapers .escapeUriPath (value .toString ());
347
- }
342
+ value = getSimpleValue (varName , name != null ? name : value .toString (), compositeOutput );
348
343
} else if (!Data .isValueOfPrimitiveType (value )) {
349
344
// Parse the value as a key/value map.
350
345
Map <String , Object > map = getMap (value );
351
346
value = getMapPropertyValue (varName , map , containsExplodeModifier , compositeOutput );
352
347
} else {
353
348
// For everything else...
354
- if (compositeOutput .requiresVarAssignment ()) {
355
- value = String .format ("%s=%s" , varName , value );
356
- }
357
- if (compositeOutput .getReservedExpansion ()) {
358
- value = CharEscapers .escapeUriPathWithoutReserved (value .toString ());
359
- } else {
360
- value = CharEscapers .escapeUriPath (value .toString ());
361
- }
349
+ value = getSimpleValue (varName , value .toString (), compositeOutput );
362
350
}
363
351
pathBuf .append (value );
364
352
}
@@ -370,6 +358,13 @@ public static String expand(String pathUri, Object parameters,
370
358
return pathBuf .toString ();
371
359
}
372
360
361
+ private static String getSimpleValue (String name , String value , CompositeOutput compositeOutput ) {
362
+ if (compositeOutput .requiresVarAssignment ()) {
363
+ return String .format ("%s=%s" , name , compositeOutput .getEncodedValue (value .toString ()));
364
+ }
365
+ return compositeOutput .getEncodedValue (value );
366
+ }
367
+
373
368
/**
374
369
* Expand the template of a composite list property.
375
370
* Eg: If d := ["red", "green", "blue"]
0 commit comments