File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed
Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ export const INVALID_METHOD_RESPONSE_BODY = {
2929const makeSureBodyExistsAndCanBeChecked = ( ctx : IResponseContext ) => {
3030 if ( ! ctx . body ) {
3131 ctx . status = 400 ;
32- ctx . body = FALLBACK_RESPONSE_BODY ;
32+ ctx . body = { ... FALLBACK_RESPONSE_BODY } ;
3333 return false ;
3434 }
3535
@@ -40,11 +40,11 @@ const makeSureBodyExistsAndCanBeChecked = (ctx: IResponseContext) => {
4040
4141 if ( typeof ctx . body !== 'object' ) {
4242 ctx . status = 400 ;
43- ctx . body = FALLBACK_RESPONSE_BODY ;
43+ ctx . body = { ... FALLBACK_RESPONSE_BODY } ;
4444 return false ;
4545 }
46- ctx . body . jsonrpc || = FALLBACK_RESPONSE_BODY . jsonrpc ;
47- ctx . body . id || = FALLBACK_RESPONSE_BODY . id ;
46+ if ( ! ctx . body . jsonrpc ) ctx . body . jsonrpc = FALLBACK_RESPONSE_BODY . jsonrpc ;
47+ if ( ! ctx . body . id ) ctx . body . id = FALLBACK_RESPONSE_BODY . id ;
4848
4949 return true ;
5050} ;
@@ -59,7 +59,7 @@ const makeSureBodyExistsAndCanBeChecked = (ctx: IResponseContext) => {
5959export const jsonRpcComplianceLayer = ( ctx : IResponseContext & ParameterizedContext ) => {
6060 if ( ! makeSureBodyExistsAndCanBeChecked ( ctx ) ) return ;
6161 if ( ctx . status === 400 ) {
62- if ( ! ctx . body . error || ! ctx . body . error . code ) ctx . body . error = FALLBACK_RESPONSE_BODY . error ;
62+ if ( ! ctx . body . error ? .code ) ctx . body . error = FALLBACK_RESPONSE_BODY . error ;
6363 if ( VALID_JSON_RPC_HTTP_REQUESTS_STATUS_CODE ) ctx . status = 200 ;
6464 }
6565} ;
You can’t perform that action at this time.
0 commit comments