File tree Expand file tree Collapse file tree 6 files changed +27
-12
lines changed Expand file tree Collapse file tree 6 files changed +27
-12
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,9 @@ function base64EncodeURL(sourceUrl) {
1010 // ignore errors
1111 }
1212 sourceUrl = encodeURI ( sourceUrl ) ;
13- return base64Encode ( sourceUrl ) ;
13+ return base64Encode ( sourceUrl ) . replace ( / \+ / g, '-' ) // Convert '+' to '-'
14+ . replace ( / \/ / g, '_' ) // Convert '/' to '_'
15+ . replace ( / = + $ / , '' ) ; // Remove ending '=';
1416}
1517
1618module . exports . base64EncodeURL = base64EncodeURL ;
Original file line number Diff line number Diff line change @@ -173,9 +173,8 @@ function process_custom_function(customFunction) {
173173 return customFunction ;
174174 }
175175 if ( customFunction . function_type === "remote" ) {
176- var encodedSource = base64EncodeURL ( customFunction . source ) . replace ( / \+ / g, '-' ) // Convert '+' to '-'
177- . replace ( / \/ / g, '_' ) // Convert '/' to '_'
178- . replace ( / = + $ / , '' ) ; // Remove ending '='
176+ var encodedSource = base64EncodeURL ( customFunction . source ) ;
177+
179178 return [ customFunction . function_type , encodedSource ] . join ( ":" ) ;
180179 }
181180 return [ customFunction . function_type , customFunction . source ] . join ( ":" ) ;
Original file line number Diff line number Diff line change @@ -7,7 +7,10 @@ function base64EncodeURL(sourceUrl) {
77 // ignore errors
88 }
99 sourceUrl = encodeURI ( sourceUrl ) ;
10- return base64Encode ( sourceUrl ) ;
10+ return base64Encode ( sourceUrl )
11+ . replace ( / \+ / g, '-' ) // Convert '+' to '-'
12+ . replace ( / \/ / g, '_' ) // Convert '/' to '_'
13+ . replace ( / = + $ / , '' ) ; // Remove ending '=';
1114}
1215
1316
Original file line number Diff line number Diff line change @@ -156,10 +156,8 @@ function process_custom_function(customFunction) {
156156 return customFunction ;
157157 }
158158 if ( customFunction . function_type === "remote" ) {
159- const encodedSource = base64EncodeURL ( customFunction . source )
160- . replace ( / \+ / g, '-' ) // Convert '+' to '-'
161- . replace ( / \/ / g, '_' ) // Convert '/' to '_'
162- . replace ( / = + $ / , '' ) ; // Remove ending '='
159+ const encodedSource = base64EncodeURL ( customFunction . source ) ;
160+
163161 return [ customFunction . function_type , encodedSource ] . join ( ":" ) ;
164162 }
165163 return [ customFunction . function_type , customFunction . source ] . join ( ":" ) ;
Original file line number Diff line number Diff line change @@ -100,6 +100,8 @@ describe("uploader", function () {
100100 } ) ;
101101 } ) ;
102102
103+
104+
103105 it ( "should successfully override original_filename" , function ( ) {
104106 return cloudinary . v2 . uploader . upload ( "http://cloudinary.com/images/old_logo.png" , {
105107 filename_override : 'overridden'
@@ -117,6 +119,17 @@ describe("uploader", function () {
117119 } ) ;
118120 } ) ;
119121
122+ it ( 'should allow upload with url safe base64 in overlay' , function ( ) {
123+ const overlayUrl = 'https://res.cloudinary.com/demo/image/upload/logos/cloudinary_full_logo_white_small.png' ;
124+ const baseImageUrl = 'http://cloudinary.com/images/old_logo.png' ;
125+
126+ const options = { transformation : { overlay : { url : overlayUrl } } } ;
127+ return cloudinary . v2 . uploader . upload ( baseImageUrl , options )
128+ . then ( ( result ) => {
129+ expect ( result ) . to . have . key ( "created_at" ) ;
130+ } ) ;
131+ } ) ;
132+
120133 describe ( "remote urls " , function ( ) {
121134 const mocked = helper . mockTest ( ) ;
122135 it ( "should send s3:// URLs to server" , function ( ) {
Original file line number Diff line number Diff line change @@ -759,18 +759,18 @@ describe("utils", function () {
759759 resource_type : "fetch" ,
760760 url : "http://cloudinary.com/images/old_logo.png"
761761 } ,
762- "fetch:aHR0cDovL2Nsb3VkaW5hcnkuY29tL2ltYWdlcy9vbGRfbG9nby5wbmc= "
762+ "fetch:aHR0cDovL2Nsb3VkaW5hcnkuY29tL2ltYWdlcy9vbGRfbG9nby5wbmc"
763763 ] ,
764764 [
765765 "fetch remote UTF" ,
766766 {
767767 url : "https://upload.wikimedia.org/wikipedia/commons/2/2b/고창갯벌.jpg"
768768 } ,
769- "fetch:aHR0cHM6Ly91cGxvYWQud2lraW1lZGlhLm9yZy93aWtpcGVkaWEvY29tbW9ucy8yLzJiLyVFQSVCMyVBMCVFQyVCMCVCRCVFQSVCMCVBRiVFQiVCMiU4Qy5qcGc= "
769+ "fetch:aHR0cHM6Ly91cGxvYWQud2lraW1lZGlhLm9yZy93aWtpcGVkaWEvY29tbW9ucy8yLzJiLyVFQSVCMyVBMCVFQyVCMCVCRCVFQSVCMCVBRiVFQiVCMiU4Qy5qcGc"
770770 ] ,
771771 [ "fetch explicit" ,
772772 "fetch:http://cloudinary.com/images/old_logo.png" ,
773- "fetch:aHR0cDovL2Nsb3VkaW5hcnkuY29tL2ltYWdlcy9vbGRfbG9nby5wbmc= " ]
773+ "fetch:aHR0cDovL2Nsb3VkaW5hcnkuY29tL2ltYWdlcy9vbGRfbG9nby5wbmc" ]
774774 ] ;
775775 [
776776 {
You can’t perform that action at this time.
0 commit comments