Skip to content

Commit

Permalink
Merge pull request #291 from rollbar/ownproperty
Browse files Browse the repository at this point in the history
Fixes #290 handle objects without Object in prototype chain
  • Loading branch information
rokob authored May 30, 2017
2 parents a880f6f + 7bbdda5 commit c285306
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 18 deletions.
8 changes: 5 additions & 3 deletions sdks/rollbar.js/src/browser/rollbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,11 @@ Rollbar.prototype.wrap = function(f, context) {

f._wrapped._isWrap = true;

for (var prop in f) {
if (f.hasOwnProperty(prop)) {
f._wrapped[prop] = f[prop];
if (f.hasOwnProperty) {
for (var prop in f) {
if (f.hasOwnProperty(prop)) {
f._wrapped[prop] = f[prop];
}
}
}
}
Expand Down
8 changes: 5 additions & 3 deletions sdks/rollbar.js/src/browser/shim.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,11 @@ Shim.prototype.wrap = function(f, context) {

f._wrapped._isWrap = true;

for (var prop in f) {
if (f.hasOwnProperty(prop)) {
f._wrapped[prop] = f[prop];
if (f.hasOwnProperty) {
for (var prop in f) {
if (f.hasOwnProperty(prop)) {
f._wrapped[prop] = f[prop];
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion sdks/rollbar.js/src/server/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function getMultipleErrors(errors) {
errArray = [];

for (key in errors) {
if (errors.hasOwnProperty(key)) {
if (Object.prototype.hasOwnProperty.call(errors, key)) {
errArray.push(errors[key]);
}
}
Expand Down
7 changes: 1 addition & 6 deletions sdks/rollbar.js/src/server/transforms.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,13 +188,8 @@ function _buildRequestData(req) {
if (req.body) {
var bodyParams = {};
if (_.isIterable(req.body)) {
var isPlainObject = req.body.constructor === undefined;

for (var k in req.body) {
var _hasOwnProperty = typeof req.body.hasOwnProperty === 'function'
&& req.body.hasOwnProperty(k);

if (_hasOwnProperty || isPlainObject) {
if (Object.prototype.hasOwnProperty.call(req.body, k)) {
bodyParams[k] = req.body[k];
}
}
Expand Down
8 changes: 3 additions & 5 deletions sdks/rollbar.js/src/utility.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ function traverse(obj, func) {

if (isObj) {
for (k in obj) {
if (obj.hasOwnProperty(k)) {
if (Object.prototype.hasOwnProperty.call(obj, k)) {
keys.push(k);
}
}
Expand All @@ -144,11 +144,9 @@ function traverse(obj, func) {
return obj;
}

/* eslint-disable no-unused-vars */
function redact(val) {
function redact() {
return '********';
}
/* eslint-enable no-unused-vars */

// from http://stackoverflow.com/a/8809472/1138191
function uuid4() {
Expand Down Expand Up @@ -238,7 +236,7 @@ function addParamsAndAccessTokenToPath(accessToken, options, params) {
var paramsArray = [];
var k;
for (k in params) {
if (params.hasOwnProperty(k)) {
if (Object.prototype.hasOwnProperty.call(params, k)) {
paramsArray.push([k, params[k]].join('='));
}
}
Expand Down

0 comments on commit c285306

Please sign in to comment.