Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit 9b0db02

Browse files
fix sprintf hack
1 parent ec82410 commit 9b0db02

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed
Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
var sprintf2 = require('sprintf-js').sprintf;
22

33
var sprintf = function(message, moduleName, data) {
4-
var dataValues = Object.keys(data).map(function(k) { return data[k]; });
5-
try {
6-
return Object.assign({}, data, {
7-
message: sprintf2.apply(sprintf2, [message, moduleName].concat(dataValues)),
8-
});
9-
} catch (error) {}
4+
if (typeof data === 'object') {
5+
var dataValues = Object.keys(data).map(function(k) { return data[k]; });
6+
try {
7+
return Object.assign({}, data, {
8+
message: sprintf2.apply(sprintf2, [message, moduleName].concat(dataValues)),
9+
});
10+
} catch (error) {}
11+
}
12+
return {
13+
message: sprintf2(message, moduleName),
14+
};
1015
};
1116

1217
module.exports = sprintf;

0 commit comments

Comments
 (0)