diff --git a/lodash.js b/lodash.js index d1f20b1f9..d3f048af0 100644 --- a/lodash.js +++ b/lodash.js @@ -11480,7 +11480,7 @@ * // => false */ function toPath(value) { - return isArray(value) ? copyArray(value) : stringToPath(value); + return isArray(value) ? arrayMap(value, String) : stringToPath(value); } /** diff --git a/test/test.js b/test/test.js index 89966bac9..eac16e5aa 100644 --- a/test/test.js +++ b/test/test.js @@ -15653,12 +15653,14 @@ deepEqual(_.toPath('a[0].b.c'), ['a', '0', 'b', 'c']); }); - test('should shallow clone array path', 2, function() { - var array = ['a', 'b', 'c'], - actual = _.toPath(array); + test('should coerce array elements to strings', 4, function() { + var array = ['a', 'b', 'c']; - deepEqual(actual, array); - notStrictEqual(actual, array); + _.each([array, _.map(array, Object)], function(value) { + var actual = _.toPath(value); + deepEqual(actual, array); + notStrictEqual(actual, array); + }); }); test('should handle complex paths', 1, function() {