mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
parent
62fc554d25
commit
0f1ca1c7cf
@ -81,6 +81,7 @@ function ensureBuffer(o) {
|
||||
* @memberof @node-red/util_util
|
||||
*/
|
||||
function cloneMessage(msg) {
|
||||
if (typeof msg !== "undefined") {
|
||||
// Temporary fix for #97
|
||||
// TODO: remove this http-node-specific fix somehow
|
||||
var req = msg.req;
|
||||
@ -98,6 +99,8 @@ function cloneMessage(msg) {
|
||||
}
|
||||
return m;
|
||||
}
|
||||
return msg;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares two objects, handling various JavaScript types.
|
||||
|
@ -143,6 +143,10 @@ describe("@node-red/util/util", function() {
|
||||
cloned.req.should.equal(msg.req);
|
||||
cloned.res.should.equal(msg.res);
|
||||
});
|
||||
it('handles undefined values without throwing an error', function() {
|
||||
var result = util.cloneMessage(undefined);
|
||||
should.not.exist(result);
|
||||
})
|
||||
});
|
||||
describe('getObjectProperty', function() {
|
||||
it('gets a property beginning with "msg."', function() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user