From 5fdf08198928b4c0eb2e3d320ac4d622e4d12ebb Mon Sep 17 00:00:00 2001 From: Gaurav Munjal Date: Sat, 4 Apr 2020 09:26:35 -0400 Subject: [PATCH] support srcDir with leading slash --- index.js | 1 + tests/index.js | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/index.js b/index.js index d0d8a90..55ff2f3 100644 --- a/index.js +++ b/index.js @@ -187,6 +187,7 @@ class Funnel extends Plugin { let inputPath = this.inputPaths[0]; if (this.srcDir) { + this.srcDir = ensureRelative(this.srcDir); inputPath = path.join(inputPath, this.srcDir); } diff --git a/tests/index.js b/tests/index.js index 2313b8d..6a6a3e7 100644 --- a/tests/index.js +++ b/tests/index.js @@ -163,6 +163,23 @@ describe('broccoli-funnel', function() { expect(assertions).to.equal(0, 'Build did not throw an error, relative path traversal worked.'); }); + it('accepts srcDir with leading slash', async function() { + let assertions = 0; + + let node = new Funnel('.', { + srcDir: '/node_modules', + destDir: 'foo', + }); + + output = createBuilder(node); + try { + await output.build(); + } catch (error) { + assertions++; + } + expect(assertions).to.equal(0, 'Build did not throw an error, relative path traversal worked.'); + }); + it('throws error on unspecified allowEmpty', async function() { let assertions = 0; let inputPath = `${FIXTURE_INPUT}/dir1`;