From 0a8f3ccb614179cf03ba44210db98d26f987aa7f Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Thu, 18 Feb 2021 23:21:55 +0200 Subject: [PATCH] Fix `new Buffer` usage --- lib/svgo/tools.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/lib/svgo/tools.js b/lib/svgo/tools.js index 71aad0c88..0b2158da8 100644 --- a/lib/svgo/tools.js +++ b/lib/svgo/tools.js @@ -12,11 +12,7 @@ exports.encodeSVGDatauri = function(str, type) { if (!type || type === 'base64') { // base64 prefix += ';base64,'; - if (Buffer.from) { - str = prefix + Buffer.from(str).toString('base64'); - } else { - str = prefix + new Buffer(str).toString('base64'); - } + str = prefix + Buffer.from(str).toString('base64'); } else if (type === 'enc') { // URI encoded str = prefix + ',' + encodeURIComponent(str); @@ -44,7 +40,7 @@ exports.decodeSVGDatauri = function(str) { if (match[2]) { // base64 - str = new Buffer(data, 'base64').toString('utf8'); + str = Buffer.from(data, 'base64').toString('utf8'); } else if (data.charAt(0) === '%') { // URI encoded str = decodeURIComponent(data);