mirror of https://github.com/gobeam/stringy.git
fix: camelcase result as pascal case issue resolved
This commit is contained in:
parent
103d950d1d
commit
5727f38c3e
|
@ -119,7 +119,11 @@ func (i *input) CamelCase(rule ...string) string {
|
||||||
// removing excess space
|
// removing excess space
|
||||||
wordArray := caseHelper(input, true, rule...)
|
wordArray := caseHelper(input, true, rule...)
|
||||||
for i, word := range wordArray {
|
for i, word := range wordArray {
|
||||||
wordArray[i] = ucfirst(word)
|
if i == 0 {
|
||||||
|
wordArray[i] = strings.ToLower(word)
|
||||||
|
} else {
|
||||||
|
wordArray[i] = ucfirst(word)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return strings.Join(wordArray, "")
|
return strings.Join(wordArray, "")
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,16 +78,16 @@ func TestInput_BooleanError(t *testing.T) {
|
||||||
func TestInput_CamelCase(t *testing.T) {
|
func TestInput_CamelCase(t *testing.T) {
|
||||||
str := New("Camel case this_complicated__string%%")
|
str := New("Camel case this_complicated__string%%")
|
||||||
val := str.CamelCase("%", "")
|
val := str.CamelCase("%", "")
|
||||||
if val != "CamelCaseThisComplicatedString" {
|
if val != "camelCaseThisComplicatedString" {
|
||||||
t.Errorf("Expected: to be %s but got: %s", "CamelCaseThisComplicatedString", val)
|
t.Errorf("Expected: to be %s but got: %s", "camelCaseThisComplicatedString", val)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestInput_CamelCaseNoRule(t *testing.T) {
|
func TestInput_CamelCaseNoRule(t *testing.T) {
|
||||||
str := New("Camel case this_complicated__string%%")
|
str := New("Camel case this_complicated__string%%")
|
||||||
val := str.CamelCase()
|
val := str.CamelCase()
|
||||||
if val != "CamelCaseThisComplicatedString%%" {
|
if val != "camelCaseThisComplicatedString%%" {
|
||||||
t.Errorf("Expected: to be %s but got: %s", "CamelCaseThisComplicatedString", val)
|
t.Errorf("Expected: to be %s but got: %s", "camelCaseThisComplicatedString", val)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,8 +100,8 @@ func TestInput_CamelCaseOddRuleError(t *testing.T) {
|
||||||
str := New("Camel case this_complicated__string%%")
|
str := New("Camel case this_complicated__string%%")
|
||||||
val := str.CamelCase("%")
|
val := str.CamelCase("%")
|
||||||
|
|
||||||
if val != "CamelCaseThisComplicatedString%%" {
|
if val != "camelCaseThisComplicatedString%%" {
|
||||||
t.Errorf("Expected: to be %s but got: %s", "CamelCaseThisComplicatedString", val)
|
t.Errorf("Expected: to be %s but got: %s", "camelCaseThisComplicatedString", val)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue