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

handle ignore_status_codes defined as strings #109

Closed
wants to merge 1 commit into from
Closed
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 lib/util/urltils.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ module.exports = {
if (config &&
config.error_collector &&
config.error_collector.ignore_status_codes) {
codes = config.error_collector.ignore_status_codes;
codes = config.error_collector.ignore_status_codes.map(function(code) {
return parseInt(code, 10);
});
}
return code >= 400 && codes.indexOf(code) === -1;
},
Expand Down
10 changes: 10 additions & 0 deletions test/urltils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,16 @@ describe("NR URL utilities", function () {
it("should mark a request for enhanced calm (brah) as an error", function () {
return expect(urltils.isError(config, 420)).true;
});

it("should handle ignore_status_codes defined as strings", function () {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is where the previous code was not working as expected

var config = {error_collector : {ignore_status_codes : ['404', '401']}};
return expect(urltils.isError(config, 401)).false;
});

it("should handle ignore_status_codes defined as integers", function () {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was working before, just added one more test to make sure

var config = {error_collector : {ignore_status_codes : [404, 401]}};
return expect(urltils.isError(config, 401)).false;
});
});

describe("copying parameters from a query hash", function () {
Expand Down