diff --git a/humanize.go b/humanize.go index 311c8be..5100bfb 100644 --- a/humanize.go +++ b/humanize.go @@ -7,6 +7,7 @@ import ( // Humanize returns first letter of sentence capitalized. // Common acronyms are capitalized as well. // Other capital letters in string are left as provided. +// // employee_salary = Employee salary // employee_id = employee ID // employee_mobile_number = Employee mobile number @@ -22,6 +23,10 @@ func (i Ident) Humanize() Ident { return New("") } + if strings.TrimSpace(i.Original) == "" { + return i + } + parts := xappend([]string{}, Titleize(i.Parts[0])) if len(i.Parts) > 1 { parts = xappend(parts, i.Parts[1:]...) diff --git a/humanize_test.go b/humanize_test.go index 2186dde..2c97a61 100644 --- a/humanize_test.go +++ b/humanize_test.go @@ -21,6 +21,11 @@ func Test_Humanize(t *testing.T) { {"first_Name", "First Name"}, {"firstName", "First Name"}, {"óbito", "Óbito"}, + {" ", " "}, + {"\n", "\n"}, + {"\r", "\r"}, + {"\t", "\t"}, + {" \n\r\t", " \n\r\t"}, } for _, tt := range table {