mirror of
				https://github.com/zadam/trilium.git
				synced 2025-11-03 20:06:08 +01:00 
			
		
		
		
	fix decoding issue for request data chunks
This commit is contained in:
		@@ -63,10 +63,15 @@ function exec(opts) {
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                let responseStr = '';
 | 
			
		||||
                let chunks = [];
 | 
			
		||||
 | 
			
		||||
                response.on('data', chunk => responseStr += chunk);
 | 
			
		||||
                response.on('data', chunk => chunks.push(chunk));
 | 
			
		||||
 | 
			
		||||
                response.on('end', () => {
 | 
			
		||||
                    // use Buffer instead of string concatenation to avoid implicit decoding for each chunk
 | 
			
		||||
                    // decode the entire data chunks explicitly as utf-8
 | 
			
		||||
                    responseStr = Buffer.concat(chunks).toString('utf-8')
 | 
			
		||||
 | 
			
		||||
                    if ([200, 201, 204].includes(response.statusCode)) {
 | 
			
		||||
                        try {
 | 
			
		||||
                            const jsonObj = responseStr.trim() ? JSON.parse(responseStr) : null;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user