Ensure _.toPath returns a new array.

This commit is contained in:
John-David Dalton
2016-03-04 18:02:28 -08:00
parent 0bad210dec
commit a6c88a173b
2 changed files with 7 additions and 1 deletions

View File

@@ -14526,7 +14526,7 @@
if (isArray(value)) {
return arrayMap(value, baseCastKey);
}
return isSymbol(value) ? [value] : stringToPath(value);
return isSymbol(value) ? [value] : copyArray(stringToPath(value));
}
/**

View File

@@ -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);