From 293fa1eed602daf2e8d984aa1dbf623a51bfaf13 Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Fri, 19 Feb 2021 01:31:06 +0200 Subject: [PATCH] Fix `new Buffer` usage (#1341) --- 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);