mirror of https://github.com/grpc/grpc-node.git
				
				
				
			grpc-js: fix error messages truncating at commas
This commit is contained in:
		
							parent
							
								
									2df072de3f
								
							
						
					
					
						commit
						dd414b6ddc
					
				|  | @ -38,7 +38,7 @@ export class MetadataStatusFilter extends BaseFilter implements Filter { | |||
|       metadata.remove('grpc-status'); | ||||
|     } | ||||
|     if (typeof metadataMap['grpc-message'] === 'string') { | ||||
|       details = decodeURI(metadataMap['grpc-message'] as string); | ||||
|       details = decodeURIComponent(metadataMap['grpc-message'] as string); | ||||
|       metadata.remove('grpc-message'); | ||||
|     } | ||||
|     return { code, details, metadata }; | ||||
|  |  | |||
|  | @ -484,7 +484,9 @@ export class Http2ServerCallStream< | |||
|         const trailersToSend = Object.assign( | ||||
|           { | ||||
|             [GRPC_STATUS_HEADER]: statusObj.code, | ||||
|             [GRPC_MESSAGE_HEADER]: encodeURI(statusObj.details as string), | ||||
|             [GRPC_MESSAGE_HEADER]: encodeURIComponent( | ||||
|               statusObj.details as string | ||||
|             ), | ||||
|           }, | ||||
|           statusObj.metadata.toHttp2Headers() | ||||
|         ); | ||||
|  |  | |||
|  | @ -699,6 +699,18 @@ describe('Other conditions', () => { | |||
|         } | ||||
|       ); | ||||
|     }); | ||||
| 
 | ||||
|     it('for an error message with a comma', done => { | ||||
|       client.unary( | ||||
|         { error: true, message: 'an error message, with a comma' }, | ||||
|         (err: ServiceError, data: any) => { | ||||
|           assert(err); | ||||
|           assert.strictEqual(err.code, grpc.status.UNKNOWN); | ||||
|           assert.strictEqual(err.details, 'an error message, with a comma'); | ||||
|           done(); | ||||
|         } | ||||
|       ); | ||||
|     }); | ||||
|   }); | ||||
| }); | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue