Skip to content

Commit

Permalink
feat: NO_PROXY: allow separator with a comma and a space
Browse files Browse the repository at this point in the history
  • Loading branch information
gajus authored Apr 2, 2021
2 parents f89883c + 5019ad7 commit debc4e6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/utilities/isUrlMatchingNoProxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
export default (subjectUrl: string, noProxy: string) => {
const subjectUrlTokens = parseUrl(subjectUrl);

const rules = noProxy.split(/[\s,]/);
const rules = noProxy.split(/[\s,]+/);

for (const rule of rules) {
const ruleMatch = rule
Expand Down
10 changes: 9 additions & 1 deletion test/global-agent/utilities/isUrlMatchingNoProxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ test('returns `true` if hosts match and ports do not match (port not present NO_
t.assert(isUrlMatchingNoProxy('http://foo.com:8000/', 'foo.com'));
});

test('returns `true` if hosts match in one of multiple rules', (t) => {
test('returns `true` if hosts match in one of multiple rules separated with a comma', (t) => {
t.assert(isUrlMatchingNoProxy('http://foo.com/', 'bar.org,foo.com,baz.io'));
});

test('returns `true` if hosts match in one of multiple rules separated with a comma and a space', (t) => {
t.assert(isUrlMatchingNoProxy('http://foo.com/', 'bar.org, foo.com, baz.io'));
});

test('returns `true` if hosts match in one of multiple rules separated with a space', (t) => {
t.assert(isUrlMatchingNoProxy('http://foo.com/', 'bar.org foo.com baz.io'));
});

0 comments on commit debc4e6

Please sign in to comment.