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

startCase removes ampersand, all symbols #3383

Closed
benterprise opened this issue Sep 21, 2017 · 10 comments
Closed

startCase removes ampersand, all symbols #3383

benterprise opened this issue Sep 21, 2017 · 10 comments
Labels

Comments

@benterprise
Copy link

_.startCase("one & two") returns "One Two", ideally it'd return "One & Two". Is there a workaround?

@jdalton
Copy link
Member

jdalton commented Sep 21, 2017

Hi @benterprise!

Is there a workaround?

Not for our casing methods. They break a string into words and then apply transformations on them.

@jdalton jdalton closed this as completed Sep 21, 2017
@KidA001
Copy link

KidA001 commented Sep 12, 2018

Odd that this method is destructive in terms that it removes characters. I would have expected it to title case what it can and leave everything else.

@mukeshkamboj
Copy link

mukeshkamboj commented Oct 17, 2018

@benterprise this is workaround.

 "JHON&JOHN C/O DR. BLah".replace(/\w+/g, _.capitalize);

result:-

"Jhon&John C/O Dr. Blah"

This is a late response but just mentioned if anyone who come across such issue can get the solution.

@animir
Copy link

animir commented Nov 28, 2018

This is weird. If function's name is startCase, then the only thing developer expects from it is making all words' first letter in capital case.

I see, this behaviour is shown in examples in docs, but still not clear. It should be clearly mentioned in docs, that it removes any spec symbols.

The best would be to have some option to disable removing spec symbols.

Thanks.

@thefilmmaking
Copy link

I have to agree with the comments. Had to use the workaround mentioned by mukesh. I can imagine the usefulness of removing all the spec symbols, but I'd say split that into a separate function.

@seanlindo
Copy link

This caused a mess in our search engine...we really were not expecting this to be a destructive operation.

@dhasilva
Copy link

Completely agree. A function called startCase should do just that and nothing else.
My case is with diacritics: 'não' becomes 'Nao'. That makes absolutely no sense.

@chryssajones
Copy link

chryssajones commented Jun 4, 2019

@benterprise's workaround didn't work for me because it capitalized the first letter after a diacritical mark: pōmaikaʻi becomes "PōMaikaʻI", which is not the desired result. You could exclude all of the possible diacritical letter variations, and that would (in theory) work, but it seems that it would be better if startCase just did not strip punctuation. Agree that should be a different function. Please update!

@DarioLopes
Copy link

And yet as of late 2019, it still not working as expected... for once I started to try this tool a little more deeper and it isn't working

@lodash lodash locked as resolved and limited conversation to collaborators Jan 7, 2020
@jdalton
Copy link
Member

jdalton commented Jan 7, 2020

Hi folks!

In v5 we will revisit this.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

No branches or pull requests

10 participants