mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-10 02:47:50 +00:00
Fix string methods to handle empty values (#4442)
* Enable strings category methods tests * Ensure escape, pad, padEnd, padStart, trim, trimEnd, trimStart, unescape return an empty string for falsey values * Coerce value to string using toString in truncate, capitalize and case methods * Ensure createCaseFirst returns an empty string for falsey values
This commit is contained in:
committed by
John-David Dalton
parent
abb54cc49a
commit
e51a424513
@@ -1,4 +1,5 @@
|
||||
import upperFirst from './upperFirst.js'
|
||||
import toString from './toString.js'
|
||||
|
||||
/**
|
||||
* Converts the first character of `string` to upper case and the remaining
|
||||
@@ -13,7 +14,7 @@ import upperFirst from './upperFirst.js'
|
||||
* capitalize('FRED')
|
||||
* // => 'Fred'
|
||||
*/
|
||||
const capitalize = (string) => upperFirst(string.toLowerCase())
|
||||
const capitalize = (string) => upperFirst(toString(string).toLowerCase())
|
||||
|
||||
|
||||
export default capitalize
|
||||
|
||||
Reference in New Issue
Block a user