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:
@@ -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 {
|
||||
|
Reference in New Issue
Block a user