Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

capitalize() works as unexpected #137

Closed
ghost opened this issue Mar 27, 2015 · 5 comments
Closed

capitalize() works as unexpected #137

ghost opened this issue Mar 27, 2015 · 5 comments

Comments

@ghost
Copy link

ghost commented Mar 27, 2015

S('this post').capitalize().camelize().s; // returns ThisPost
But
S('this post').camelize().capitalize().s; // returns Thispost

capitalize() IMO should only change the first character and not worry about the rest.

@az7arul
Copy link
Collaborator

az7arul commented Mar 28, 2015

This seems to be the expected behavior. Both python and ruby return

'thisPost'.capitalize()
"Thispost"

@az7arul az7arul closed this as completed Mar 28, 2015
@jprichardson
Copy link
Owner

@MurWade notice the order of your two snippets... in the first you're doing capitalize first and then camelize, but on the second you're switching the order. You can see that only the first character is indeed capitalized: https://github.com/jprichardson/string.js/blob/3.1.1/lib/string.js#L86

But the question remains, should we be lower casing the rest of the string or leave it alone?

@az7arul az7arul reopened this Mar 28, 2015
@ghost
Copy link
Author

ghost commented Mar 28, 2015

@jprichardson exactly. i think it would make sense to leave the rest of the chars the way it is.

@az7arul
Copy link
Collaborator

az7arul commented Mar 28, 2015

I don't think it makes sense to leave the rest alone since most languages define capitalize as a method that uppercases first character and downcases rest.

@jprichardson
Copy link
Owner

@az7arul I'm good with that. Since that's the current behavior and Ruby/Python seem to follow that behavior, let's leave it as is then. @MurWade Closing. If I missed something in my understanding, let me know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants