From 3a0fbe790e1e3ec2c5dffa15b670049fb9b34725 Mon Sep 17 00:00:00 2001 From: Carson Full Date: Sun, 6 Oct 2024 13:26:30 -0500 Subject: [PATCH] Fix HttpAdapter proxy `this` scoping --- src/core/http/http.module.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/core/http/http.module.ts b/src/core/http/http.module.ts index 4ccb0e2799..3f55d505c4 100644 --- a/src/core/http/http.module.ts +++ b/src/core/http/http.module.ts @@ -22,11 +22,8 @@ import { HttpAdapter, HttpAdapterHost } from './http.adapter'; ]), ); return new Proxy(host, { - get(_, key, receiver) { + get(_, key) { const { httpAdapter } = host; - if (key === 'httpAdapter') { - return httpAdapter; - } if (key === 'constructor') { return HttpAdapter.constructor; } @@ -36,7 +33,8 @@ import { HttpAdapter, HttpAdapterHost } from './http.adapter'; if (!httpAdapter) { throw new Error('HttpAdapter is not yet available'); } - return Reflect.get(httpAdapter, key, receiver); + const val = Reflect.get(httpAdapter, key, httpAdapter); + return typeof val === 'function' ? val.bind(httpAdapter) : val; }, }); },