Skip to content

Commit

Permalink
style: update
Browse files Browse the repository at this point in the history
  • Loading branch information
zkochan committed Jan 18, 2024
1 parent d57f791 commit 48185aa
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions network/agent/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ export type AgentOptions = ProxyAgentOptions & {
noProxy?: boolean | string
}

export function getAgent(uri: string, opts: AgentOptions) {
export function getAgent (uri: string, opts: AgentOptions) {
if ((opts.httpProxy || opts.httpsProxy) && !checkNoProxy(uri, opts)) {
const proxyAgent = getProxyAgent(uri, opts)
if (proxyAgent) return proxyAgent
}
return getNonProxyAgent(uri, opts)
}

function getNonProxyAgent(uri: string, opts: AgentOptions) {
function getNonProxyAgent (uri: string, opts: AgentOptions) {
const parsedUri = new URL(uri)
const host = nerfDart(uri)
const isHttps = parsedUri.protocol === 'https:'
Expand Down Expand Up @@ -87,7 +87,7 @@ function getNonProxyAgent(uri: string, opts: AgentOptions) {
return agent
}

function checkNoProxy(uri: string, opts: { noProxy?: boolean | string }) {
function checkNoProxy (uri: string, opts: { noProxy?: boolean | string }) {
const host = new URL(uri).hostname
.split('.')
.filter(x => x)
Expand Down
12 changes: 6 additions & 6 deletions network/proxy-agent/proxy-agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export interface ProxyAgentOptions {
}
}

export function getProxyAgent(uri: string, opts: ProxyAgentOptions) {
export function getProxyAgent (uri: string, opts: ProxyAgentOptions) {
const parsedUri = new URL(uri)
const pxuri = getProxyUri(parsedUri, opts)
if (!pxuri) return
Expand Down Expand Up @@ -56,7 +56,7 @@ export function getProxyAgent(uri: string, opts: ProxyAgentOptions) {
return proxy
}

function getProxyUri(
function getProxyUri (
uri: URL,
opts: {
httpProxy?: string
Expand Down Expand Up @@ -98,7 +98,7 @@ function getProxyUri(
}
}

function getProxy(
function getProxy (
proxyUrl: URL,
opts: {
ca?: string | string[]
Expand Down Expand Up @@ -142,7 +142,7 @@ function getProxy(
return undefined
}

function getAuth(user: { username?: string; password?: string }) {
function getAuth (user: { username?: string; password?: string }) {
if (!user.username) {
return undefined
}
Expand All @@ -157,13 +157,13 @@ const extraOpts = Symbol('extra agent opts')

// This is a workaround for this issue: https://github.com/TooTallNate/node-https-proxy-agent/issues/89
class PatchedHttpsProxyAgent extends HttpsProxyAgent {
constructor(opts: any) {
constructor (opts: any) {
super(opts)

this[extraOpts] = opts
}

callback(req: any, opts: any) {
callback (req: any, opts: any) {
return super.callback(req, { ...this[extraOpts], ...opts })
}
}

0 comments on commit 48185aa

Please sign in to comment.