From 6017260776c4c86b42bd0f6eb3da99f563e7cfd1 Mon Sep 17 00:00:00 2001 From: paera Date: Thu, 13 Jan 2022 11:53:48 +0100 Subject: [PATCH] Fixes DeprecationWarning: Buffer() is deprecated due to security and usability issues --- test/tests/creation_date.js | 2 +- test/tests/po_custom_headers.js | 2 +- test/tests/po_header.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/tests/creation_date.js b/test/tests/creation_date.js index 8048fbd..ca813f1 100644 --- a/test/tests/creation_date.js +++ b/test/tests/creation_date.js @@ -8,7 +8,7 @@ exports['test creation date'] = function (assert, cb) { sources = {'dummy': ''}, result = jsxgettext.generate(sources, opts); - var parsed = gettextParser.po.parse(new Buffer(result)); + var parsed = gettextParser.po.parse(Buffer.from(result)); var timestamp = parsed.headers["pot-creation-date"].match(/(\d{4}-\d{2}-\d{2} \d{2}:\d{2}[+-]\d{4})/)[1]; assert.ok(timestamp.length > 0, 'Valid timestamp'); // Timestamp should be at most 2 minutes in the past since it is truncated to minute diff --git a/test/tests/po_custom_headers.js b/test/tests/po_custom_headers.js index b20571b..a6476e4 100644 --- a/test/tests/po_custom_headers.js +++ b/test/tests/po_custom_headers.js @@ -11,7 +11,7 @@ exports['test po custom headers'] = function (assert, cb) { }, sources = {'dummy': ''}, result = jsxgettext.generate(sources, opts), - parsed = gettextParser.po.parse(new Buffer(result)); + parsed = gettextParser.po.parse(Buffer.from(result)); var headerCustom = { "project-id-version": "MyProject 1.0", diff --git a/test/tests/po_header.js b/test/tests/po_header.js index ad3da19..f0e2d0c 100644 --- a/test/tests/po_header.js +++ b/test/tests/po_header.js @@ -7,7 +7,7 @@ exports['test po header'] = function (assert, cb) { var opts = {}, sources = {'dummy': ''}, result = jsxgettext.generate(sources, opts), - parsed = gettextParser.po.parse(new Buffer(result)); + parsed = gettextParser.po.parse(Buffer.from(result)); var headerDefaults = { "project-id-version": "PACKAGE VERSION",