File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed
packages/sdk.geometry-api-sdk-v2/src Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -193,7 +193,18 @@ export class UtilsApi extends BaseAPI {
193193 return this . download ( url , options ) as any ;
194194 } else {
195195 // All other source URLs are called via the download-image endpoint
196- return new AssetsApi ( this . configuration ) . downloadImage ( sessionId , url , options ) ;
196+
197+ // Use a universal base64 encoder for browser and Node.js environments
198+ const encodedUrl =
199+ typeof window !== 'undefined' && window . btoa
200+ ? window . btoa (
201+ encodeURIComponent ( url ) . replace ( / % ( [ 0 - 9 A - F ] { 2 } ) / g, ( _ , p1 ) =>
202+ String . fromCharCode ( parseInt ( p1 , 16 ) )
203+ )
204+ )
205+ : Buffer . from ( url , 'utf-8' ) . toString ( 'base64' ) ;
206+
207+ return new AssetsApi ( this . configuration ) . downloadImage ( sessionId , encodedUrl , options ) ;
197208 }
198209 }
199210
You can’t perform that action at this time.
0 commit comments