Skip to content

Commit 3ecf19c

Browse files
committed
fix(config): fix noproxy
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
1 parent f17aca5 commit 3ecf19c

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

lib/utils/config/definitions.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -1204,7 +1204,10 @@ define('noproxy', {
12041204
Also accepts a comma-delimited string.
12051205
`,
12061206
flatten (key, obj, flatOptions) {
1207-
flatOptions.noProxy = obj[key].join(',')
1207+
if (Array.isArray(obj[key]))
1208+
flatOptions.noProxy = obj[key].join(',')
1209+
else
1210+
flatOptions.noProxy = obj[key]
12081211
},
12091212
})
12101213

test/lib/utils/config/definitions.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -463,14 +463,22 @@ t.test('search options', t => {
463463
t.end()
464464
})
465465

466-
t.test('noProxy', t => {
466+
t.test('noProxy - array', t => {
467467
const obj = { noproxy: ['1.2.3.4,2.3.4.5', '3.4.5.6'] }
468468
const flat = {}
469469
definitions.noproxy.flatten('noproxy', obj, flat)
470470
t.strictSame(flat, { noProxy: '1.2.3.4,2.3.4.5,3.4.5.6' })
471471
t.end()
472472
})
473473

474+
t.test('noProxy - string', t => {
475+
const obj = { noproxy: '1.2.3.4,2.3.4.5,3.4.5.6' }
476+
const flat = {}
477+
definitions.noproxy.flatten('noproxy', obj, flat)
478+
t.strictSame(flat, { noProxy: '1.2.3.4,2.3.4.5,3.4.5.6' })
479+
t.end()
480+
})
481+
474482
t.test('maxSockets', t => {
475483
const obj = { maxsockets: 123 }
476484
const flat = {}

0 commit comments

Comments
 (0)