Skip to content

Commit

Permalink
Fix new Buffer usage (#1341)
Browse files Browse the repository at this point in the history
  • Loading branch information
XhmikosR committed Feb 18, 2021
1 parent 136a52c commit 293fa1e
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions lib/svgo/tools.js
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 293fa1e

Please sign in to comment.