From 8eca0191573d2386ca6eb786c25423a2d7bf5907 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Mon, 25 Jul 2016 11:10:36 -0700 Subject: [PATCH] Support paths as Buffers --- lib/common/asar.js | 4 ++++ spec/asar-spec.js | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/lib/common/asar.js b/lib/common/asar.js index ceb58df14d87..fcb26ba97b71 100644 --- a/lib/common/asar.js +++ b/lib/common/asar.js @@ -37,6 +37,10 @@ return [false] } + if (Buffer.isBuffer(p)) { + p = p.toString() + } + if (typeof p !== 'string') { return [false] } diff --git a/spec/asar-spec.js b/spec/asar-spec.js index a8fc6a9ade4d..45278c302495 100644 --- a/spec/asar-spec.js +++ b/spec/asar-spec.js @@ -13,6 +13,11 @@ describe('asar package', function () { var fixtures = path.join(__dirname, 'fixtures') describe('node api', function () { + it('supports paths specified as a Buffer', function () { + var file = new Buffer(path.join(fixtures, 'asar', 'a.asar', 'file1')) + assert.equal(fs.existsSync(file), true) + }) + describe('fs.readFileSync', function () { it('does not leak fd', function () { var readCalls = 1