Skip to content

Commit 9dfb680

Browse files
aredridelljharb
authored andcommitted
[Refactor] Avoid setting message property on primitives; use strict mode to catch this
1 parent da8ca46 commit 9dfb680

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/test.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict';
2+
13
var deepEqual = require('deep-equal');
24
var defined = require('defined');
35
var path = require('path');
@@ -497,7 +499,7 @@ Test.prototype['throws'] = function (fn, expected, msg, extra) {
497499
fn();
498500
} catch (err) {
499501
caught = { error: err };
500-
if ((err != null) && (!isEnumerable(err, 'message') || !has(err, 'message'))) {
502+
if (Object(err) === err && (!isEnumerable(err, 'message') || !has(err, 'message'))) {
501503
var message = err.message;
502504
delete err.message;
503505
err.message = message;

0 commit comments

Comments
 (0)