mirror of
https://github.com/node-red/node-red-nodes.git
synced 2025-03-01 10:37:43 +00:00
handle multi-line base64 strings
This commit is contained in:
parent
e61da83d5d
commit
8b53d09ad3
@ -14,9 +14,10 @@ module.exports = function(RED) {
|
|||||||
}
|
}
|
||||||
else if (typeof msg.payload === "string") {
|
else if (typeof msg.payload === "string") {
|
||||||
// Take base64 string and make into binary buffer
|
// Take base64 string and make into binary buffer
|
||||||
var regexp = new RegExp('^[A-Za-z0-9+\/=]*$');
|
var load = msg.payload.replace(/\s+/g,''); // remove any whitespace
|
||||||
if ( regexp.test(msg.payload) && (msg.payload.length % 4 === 0) ) {
|
var regexp = new RegExp('^[A-Za-z0-9+\/=]*$'); // check it only contains valid characters
|
||||||
msg.payload = new Buffer(msg.payload,'base64');
|
if ( regexp.test(load) && (load.length % 4 === 0) ) {
|
||||||
|
msg.payload = new Buffer(load,'base64');
|
||||||
node.send(msg);
|
node.send(msg);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name" : "node-red-node-base64",
|
"name" : "node-red-node-base64",
|
||||||
"version" : "0.0.6",
|
"version" : "0.0.7",
|
||||||
"description" : "A Node-RED node to pack and unpack objects to base64 format",
|
"description" : "A Node-RED node to pack and unpack objects to base64 format",
|
||||||
"dependencies" : {
|
"dependencies" : {
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user