From a6c88a173b7cf15c8779722de1e74b82d55de28b Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Fri, 4 Mar 2016 18:02:28 -0800 Subject: [PATCH] Ensure `_.toPath` returns a new array. --- lodash.js | 2 +- test/test.js | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lodash.js b/lodash.js index 8f3552b25..34bfd9a63 100644 --- a/lodash.js +++ b/lodash.js @@ -14526,7 +14526,7 @@ if (isArray(value)) { return arrayMap(value, baseCastKey); } - return isSymbol(value) ? [value] : stringToPath(value); + return isSymbol(value) ? [value] : copyArray(stringToPath(value)); } /** diff --git a/test/test.js b/test/test.js index 42f663c81..45dced171 100644 --- a/test/test.js +++ b/test/test.js @@ -22108,6 +22108,12 @@ }); }); + QUnit.test('should a new path array', function(assert) { + assert.expect(1); + + assert.notStrictEqual(_.toPath('a.b.c'), _.toPath('a.b.c')); + }); + QUnit.test('should not coerce symbols to strings', function(assert) { assert.expect(4);