Skip to content

Commit

Permalink
fix(config): fix noproxy
Browse files Browse the repository at this point in the history
The flattener worked for everything except for when you are using
`npm config set` itself.  Now it works for both.

PR-URL: #3508
Credit: @wraithgar
Close: #3508
Reviewed-by: @nlf
  • Loading branch information
wraithgar committed Jul 12, 2021
1 parent f17aca5 commit 3ecf19c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
5 changes: 4 additions & 1 deletion lib/utils/config/definitions.js
Expand Up @@ -1204,7 +1204,10 @@ define('noproxy', {
Also accepts a comma-delimited string.
`,
flatten (key, obj, flatOptions) {
flatOptions.noProxy = obj[key].join(',')
if (Array.isArray(obj[key]))
flatOptions.noProxy = obj[key].join(',')
else
flatOptions.noProxy = obj[key]
},
})

Expand Down
10 changes: 9 additions & 1 deletion test/lib/utils/config/definitions.js
Expand Up @@ -463,14 +463,22 @@ t.test('search options', t => {
t.end()
})

t.test('noProxy', t => {
t.test('noProxy - array', t => {
const obj = { noproxy: ['1.2.3.4,2.3.4.5', '3.4.5.6'] }
const flat = {}
definitions.noproxy.flatten('noproxy', obj, flat)
t.strictSame(flat, { noProxy: '1.2.3.4,2.3.4.5,3.4.5.6' })
t.end()
})

t.test('noProxy - string', t => {
const obj = { noproxy: '1.2.3.4,2.3.4.5,3.4.5.6' }
const flat = {}
definitions.noproxy.flatten('noproxy', obj, flat)
t.strictSame(flat, { noProxy: '1.2.3.4,2.3.4.5,3.4.5.6' })
t.end()
})

t.test('maxSockets', t => {
const obj = { maxsockets: 123 }
const flat = {}
Expand Down

0 comments on commit 3ecf19c

Please sign in to comment.