Compare commits

..

12 Commits

Author SHA1 Message Date
Nick O'Leary
2137211d42 Capture workspace dirty state when quick-adding junction
Fixes #4282
2023-08-16 15:58:08 +01:00
Nick O'Leary
f719e5ad49 Merge pull request #4278 from node-red/update-tour
Update tour
2023-08-16 10:23:07 +01:00
Nick O'Leary
20557f20db Update tour for 3.1.0 2023-08-15 20:36:07 +01:00
Nick O'Leary
054d6870d5 Merge pull request #4267 from kazuhitoyokoi/dev-tostring4filenodes
Fix handling in file nodes when number is specified as file name
2023-08-14 17:28:07 +01:00
Nick O'Leary
04aa4897fe Merge pull request #4275 from kazuhitoyokoi/dev-fixtest4jsonnode
Fix test cases of JSON node
2023-08-14 14:51:02 +01:00
Kazuhito Yokoi
72b22a4845 Fix test cases of JSON node 2023-08-14 22:44:02 +09:00
Kazuhito Yokoi
3fd2b5f4e1 Merge branch 'dev' into dev-tostring4filenodes 2023-08-14 21:16:57 +09:00
Kazuhito Yokoi
8a4128defb Fix handling in file nodes when 0 is specified as file name 2023-08-14 19:53:00 +09:00
Nick O'Leary
97470e94f1 Merge pull request #4262 from sammachin/patch-3
Handle 204 in httprequest JSON
2023-08-14 11:10:24 +01:00
Kazuhito Yokoi
0dd771351d Fix handling in file nodes when number is specified as file name 2023-08-06 20:35:33 +09:00
Sam Machin
ec86ec188b Update Test
I've changed the DELETE test to expect an empty object as the node is requesting an object response, this will therefore cover testing the new functionality.
The subsequent HEAD test also expects a 204 response but the requested type is txt so that will still expect an empty string response.
2023-08-02 14:32:39 +01:00
Sam Machin
2b01a3fcd3 Handle 204 in httprequest JSON
If the http statusCode is 204 (Success, No Content) and the node return type is set to JSON this sets msg.payload as an empty json object so as to supress the JSON parse error
2023-08-02 14:15:29 +01:00
7 changed files with 43 additions and 25 deletions

View File

@@ -1398,6 +1398,7 @@ RED.view = (function() {
}
historyEvent = {
t:'add',
dirty: RED.nodes.dirty(),
junctions:[nn]
}
} else {

View File

@@ -1,17 +1,17 @@
export default {
version: "3.1.0-beta.4",
version: "3.1.0",
steps: [
{
titleIcon: "fa fa-map-o",
title: {
"en-US": "Welcome to Node-RED 3.1 Beta 4!",
"ja": "Node-RED 3.1 ベータ3へようこそ!",
"fr": "Bienvenue dans Node-RED 3.1 Bêta 4 !"
"en-US": "Welcome to Node-RED 3.1!",
"ja": "Node-RED 3.1へようこそ!",
"fr": "Bienvenue dans Node-RED 3.1!"
},
description: {
"en-US": "<p>This is the fourth beta release for 3.1.0. This is mostly a bug fix release, so you can skip this tour if you've tried the other betas.</p><p>If not, stick around to see what's new in Node-RED 3.1.</p>",
"ja": "<p>これは3.1.0の4回目のベータリリースです。不具合修正のリリースのため、もし他のベータ版を試したことがある場合は、このツアーを読み飛ばしてもかまいません。</p><p>そうでない場合は、Node-RED 3.1の新機能を確認してください。</p>",
"fr": "<p>Il s'agit de la quatrième bêta de la version 3.1.0. Cette version apporte principalement la correction de bugs, vous pouvez donc ignorer cette visite guidée si vous avez essayé les autres versions bêta.</p><p>Si ce n'est pas le cas, restez dans les parages pour voir les nouveautés de Node-RED 3.1.</p>"
"en-US": "<p>Let's take a moment to discover the new features in this release.</p>",
"ja": "<p>本リリースの新機能を見つけてみましょう。</p>",
"fr": "<p>Prenons un moment pour découvrir les nouvelles fonctionnalités de cette version.</p>"
}
},
{
@@ -101,18 +101,6 @@ export default {
<p>Cliquer dessus ouvrira la barre latérale d'aide affichant l'aide pour ce noeud.</p>`
}
},
{
title: {
"en-US": "And lots more...",
"ja": "そしてさらに沢山あります...",
"fr": "Et plus encore..."
},
description: {
"en-US": `<p>Of course we have everything from 3.1.0-beta.1 as well....</p>`,
"ja": `<p>もちろん3.1.0 ベータ1の全ての機能があります....</p>`,
"fr": `<p>Bien sûr, nous avons également tout ce qui concerne la version 3.1.0-beta.1...</p>`
}
},
{
title: {
"en-US": "Improved Context Menu",

View File

@@ -637,6 +637,7 @@ in your Node-RED user directory (${RED.settings.userDir}).
msg.payload = msg.payload.toString('utf8'); // txt
if (node.ret === "obj") {
if (msg.statusCode == 204){msg.payload= "{}"};
try { msg.payload = JSON.parse(msg.payload); } // obj
catch(e) { node.warn(RED._("httpin.errors.json-error")); }
}

View File

@@ -68,6 +68,9 @@ module.exports = function(RED) {
node.error(err,msg);
return done();
} else {
if (typeof value !== 'string' && value !== null && value !== undefined) {
value = value.toString();
}
processMsg2(msg,nodeSend,value,done);
}
});
@@ -278,7 +281,6 @@ module.exports = function(RED) {
}
RED.nodes.registerType("file",FileNode);
function FileInNode(n) {
// Read a file
RED.nodes.createNode(this,n);
@@ -314,6 +316,9 @@ module.exports = function(RED) {
node.error(err,msg);
return done();
} else {
if (typeof value !== 'string' && value !== null && value !== undefined) {
value = value.toString();
}
processMsg2(msg, nodeSend, (value || "").replace(/\t|\r|\n/g,''), nodeDone);
}
});

View File

@@ -667,7 +667,7 @@ describe('HTTP Request Node', function() {
var n2 = helper.getNode("n2");
n2.on("input", function(msg) {
try {
msg.should.have.property('payload','');
msg.should.have.property('payload',{});
msg.should.have.property('statusCode',204);
done();
} catch(err) {

View File

@@ -173,7 +173,7 @@ describe('JSON node', function() {
});
logEvents.should.have.length(1);
logEvents[0][0].should.have.a.property('msg');
logEvents[0][0].msg.should.startWith("Unexpected token o");
logEvents[0][0].msg.should.match(/^Unexpected token (o|'o')/);
logEvents[0][0].should.have.a.property('level',helper.log().ERROR);
done();
} catch(err) { done(err) }
@@ -199,7 +199,7 @@ describe('JSON node', function() {
});
logEvents.should.have.length(1);
logEvents[0][0].should.have.a.property('msg');
logEvents[0][0].msg.should.startWith("Unexpected token o");
logEvents[0][0].msg.should.match(/^Unexpected token (o|'o')/);
logEvents[0][0].should.have.a.property('level',helper.log().ERROR);
done();
} catch(err) { done(err) }

View File

@@ -121,7 +121,6 @@ describe('file Nodes', function() {
});
});
it('should write to a file using RED.settings.fileWorkingDirectory', function(done) {
var flow = [{id:"fileNode1", type:"file", name: "fileNode", "filename":relativePathToFile, "appendNewline":false, "overwriteFile":true, wires: [["helperNode1"]]},
{id:"helperNode1", type:"helper"}];
@@ -145,7 +144,6 @@ describe('file Nodes', function() {
});
});
it('should write multi-byte string to a file', function(done) {
var flow = [{id:"fileNode1", type:"file", name: "fileNode", "filename":fileToTest, "appendNewline":false, "overwriteFile":true, wires: [["helperNode1"]]},
{id:"helperNode1", type:"helper"}];
@@ -447,6 +445,31 @@ describe('file Nodes', function() {
n1.receive({payload:"typedInput", _user_specified_filename:fileToTest});
});
});
it('should support number in msg._user_specified_filename', function (done) {
var flow = [{id:"fileNode1", type:"file", filename:"_user_specified_filename", filenameType:"msg", name:"fileNode", "appendNewline":false, "overwriteFile":true, wires:[["helperNode1"]]},
{id:"helperNode1", type:"helper"}];
helper.load(fileNode, flow, function () {
RED.settings.fileWorkingDirectory = resourcesDir;
var n1 = helper.getNode("fileNode1");
var n2 = helper.getNode("helperNode1");
n2.on("input", function (msg) {
try {
var fileToTest = path.join(resourcesDir, "123");
var f = fs.readFileSync(fileToTest);
f.should.have.length(4);
fs.unlinkSync(fileToTest);
msg.should.have.property("payload", "test");
done();
}
catch (e) {
done(e);
}
});
n1.receive({payload: "test", _user_specified_filename: 123});
});
});
it('should use env.TEST_FILE set in nodes typedInput', function(done) {
var flow = [{id:"fileNode1", type:"file", filename:"TEST_FILE", filenameType: "env", name: "fileNode", "appendNewline":true, "overwriteFile":true, wires: [["helperNode1"]]},
{id:"helperNode1", type:"helper"}];