mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-04 17:07:49 +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 words from './words.js'
|
||||
import toString from './toString.js'
|
||||
|
||||
/**
|
||||
* Converts `string`, as space separated words, to upper case.
|
||||
@@ -20,7 +21,7 @@ import words from './words.js'
|
||||
* // => 'FOO BAR'
|
||||
*/
|
||||
const upperCase = (string) => (
|
||||
words(`${string}`.replace(/['\u2019]/g, '')).reduce((result, word, index) => (
|
||||
words(toString(string).replace(/['\u2019]/g, '')).reduce((result, word, index) => (
|
||||
result + (index ? ' ' : '') + word.toUpperCase()
|
||||
), '')
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user