@@ -39,6 +39,7 @@ public class Url {
3939 Transformation posterTransformation = null ;
4040 String posterSource = null ;
4141 Url posterUrl = null ;
42+ boolean forceVersion = true ;
4243
4344 private static final String CL_BLANK = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" ;
4445 public static final String [] DEFAULT_VIDEO_SOURCE_TYPES = {"webm" , "mp4" , "ogv" };
@@ -312,6 +313,19 @@ public Url poster(Object poster) {
312313 }
313314 }
314315
316+ /**
317+ * Indicates whether to add '/v1/' to the URL when the public ID includes folders and a 'version' value was
318+ * not defined.
319+ * When no version is explicitly specified and the public id contains folders, a default v1 version
320+ * is added to the url. This boolean can disable that behaviour.
321+ * @param forceVersion Whether to add the version to the url.
322+ * @return This same Url instance for chaining.
323+ */
324+ public Url forceVersion (boolean forceVersion ){
325+ this .forceVersion = forceVersion ;
326+ return this ;
327+ }
328+
315329 public String generate () {
316330 return generate (null );
317331 }
@@ -357,7 +371,8 @@ public String generate(String source) {
357371 source = finalizedSource [0 ];
358372 String sourceToSign = finalizedSource [1 ];
359373
360- if (sourceToSign .contains ("/" ) && !StringUtils .hasVersionString (sourceToSign ) && !httpSource && StringUtils .isEmpty (version )) {
374+ if (forceVersion && sourceToSign .contains ("/" ) && !StringUtils .hasVersionString (sourceToSign ) &&
375+ !httpSource && StringUtils .isEmpty (version )) {
361376 version = "1" ;
362377 }
363378
0 commit comments