Skip to content

Commit

Permalink
fix(request-manager): options may be undefined in interceptor
Browse files Browse the repository at this point in the history
  • Loading branch information
martykan committed Jan 30, 2025
1 parent 7a170de commit f4b8c91
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions packages/request-manager/src/interceptor/overloadHttpRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ const getIdentityName = (proxyAuthorization?: http.OutgoingHttpHeader) => {
};

/** Should the request be blocked if Tor isn't enabled? */
export const getIsTorRequired = (options: Readonly<http.RequestOptions>) =>
!!options.headers?.['Proxy-Authorization'];
export const getIsTorRequired = (options?: Readonly<http.RequestOptions>) =>
!!options?.headers?.['Proxy-Authorization'];

const getIdentityForAgent = (options: Readonly<http.RequestOptions>) => {
if (options.headers?.['Proxy-Authorization']) {
const getIdentityForAgent = (options?: Readonly<http.RequestOptions>) => {
if (options?.headers?.['Proxy-Authorization']) {
// Use Proxy-Authorization header to define proxy identity
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Proxy-Authorization
return getIdentityName(options.headers['Proxy-Authorization']);
}
if (options.headers?.Upgrade === 'websocket') {
if (options?.headers?.Upgrade === 'websocket') {
// Create random identity for each websocket connection
return `WebSocket/${options.host}/${getWeakRandomId(16)}`;
}
Expand Down

0 comments on commit f4b8c91

Please sign in to comment.