Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed correlationHeaderExcludedDomains only cares about first value #194

Merged
merged 1 commit into from
Mar 3, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Library/Util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,9 @@ class Util {

for (let i = 0; i < excludedDomains.length; i++) {
let regex = new RegExp(excludedDomains[i].replace(/\./g,"\.").replace(/\*/g,".*"));
return !regex.test(url.parse(requestUrl).hostname);
if (regex.test(url.parse(requestUrl).hostname)) {
return false;
}
}

return true;
Expand Down
6 changes: 5 additions & 1 deletion Tests/Library/Util.tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,14 +179,18 @@ describe("Library/Util", () => {
});

it("should return false if domain is on the excluded list", () => {
let client = <any>{ config: { correlationHeaderExcludedDomains: ["bing.com"] } };
let client = <any>{ config: { correlationHeaderExcludedDomains: ["bing.com", "bing.net"] } };
let url = "http://bing.com/search?q=node";

assert.equal(Util.canIncludeCorrelationHeader(client, url), false);

let urlSecure = "https://bing.com/search?q=node";

assert.equal(Util.canIncludeCorrelationHeader(client, urlSecure), false);

let secondDomainUrl = "http://bing.net/search?q=node";

assert.equal(Util.canIncludeCorrelationHeader(client, secondDomainUrl), false);
});

it("can take wildcards in the excluded domain list", () => {
Expand Down