mirror of
https://github.com/node-red/node-red-nodes.git
synced 2023-10-10 13:36:58 +02: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") {
|
||||
// Take base64 string and make into binary buffer
|
||||
var regexp = new RegExp('^[A-Za-z0-9+\/=]*$');
|
||||
if ( regexp.test(msg.payload) && (msg.payload.length % 4 === 0) ) {
|
||||
msg.payload = new Buffer(msg.payload,'base64');
|
||||
var load = msg.payload.replace(/\s+/g,''); // remove any whitespace
|
||||
var regexp = new RegExp('^[A-Za-z0-9+\/=]*$'); // check it only contains valid characters
|
||||
if ( regexp.test(load) && (load.length % 4 === 0) ) {
|
||||
msg.payload = new Buffer(load,'base64');
|
||||
node.send(msg);
|
||||
}
|
||||
else {
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"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",
|
||||
"dependencies" : {
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user