Skip to content

Commit

Permalink
fix: https-proxy-agent usage after version bump [NONE] (#206)
Browse files Browse the repository at this point in the history
* fix: https-proxy-agent usage after version bump [NONE]

* chore: pin version of ESM only modules [NONE]
  • Loading branch information
marcolink authored Oct 11, 2023
1 parent 96162e1 commit 9a6a0f4
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 51 deletions.
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ updates:
time: "00:00"
timezone: UTC
open-pull-requests-limit: 10
ignore:
- dependency-name: bfj # ignore ESM only versions
versions:
- ">=8.0.0"
- dependency-name: figures # ignore ESM only versions
versions:
- ">=4.0.0"
commit-message:
prefix: build
include: scope
9 changes: 4 additions & 5 deletions lib/proxy.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { URL, format } from 'url'
import HttpsProxyAgent from 'https-proxy-agent'
import { format, URL } from 'url'
import { HttpsProxyAgent } from 'https-proxy-agent'

function serializeAuth ({ username, password } = {}) {
if (!username) {
Expand Down Expand Up @@ -62,7 +62,6 @@ export function agentFromProxy (proxy) {
delete process.env[envStr]
delete process.env[envStr.toUpperCase()]
})
const { host, port, protocol } = proxy
const agent = new HttpsProxyAgent({ host, port, protocol })
return agent

return new HttpsProxyAgent(proxyObjectToString(proxy))
}
90 changes: 48 additions & 42 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
"prepush": "npm run test"
},
"dependencies": {
"bfj": "^8.0.0",
"bfj": "7.1.0",
"date-fns": "^2.28.0",
"figures": "^5.0.0",
"figures": "3.2.0",
"https-proxy-agent": "^7.0.2",
"lodash.clonedeep": "^4.5.0",
"uuid": "^9.0.1"
Expand Down
5 changes: 3 additions & 2 deletions test/proxy.test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import HttpsProxyAgent from 'https-proxy-agent'
import { HttpsProxyAgent } from 'https-proxy-agent'
import {
proxyStringToObject,
proxyObjectToString,
agentFromProxy
} from '../lib/proxy'
import expect from 'expect'

jest.mock('https-proxy-agent')

Expand Down Expand Up @@ -127,7 +128,7 @@ test('agentFromProxy creates https agent and removes proxy env variables', () =>
const agent = agentFromProxy(agentParams)

expect(agent).toBeInstanceOf(HttpsProxyAgent)
expect(HttpsProxyAgent.mock.calls[0][0]).toMatchObject(agentParams)
expect(HttpsProxyAgent.mock.calls[0][0]).toBe(proxyObjectToString(agentParams))

expect(process.env).not.toHaveProperty('HTTP_PROXY')
expect(process.env).not.toHaveProperty('http_proxy')
Expand Down

0 comments on commit 9a6a0f4

Please sign in to comment.