-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
isEmpty returns true for whitespace only strings #747
Comments
I'm 50-50 on this one, just because we can't "see" the space character, doesn't mean it's not there (empty)... On the other hand, having this as a choice with |
@profnandaa I think that having an option for not allowing whitespace, as mentioned, is a good choice, so will make a PR to reflect this, and allow any other opinions to come up in PR review. |
@profnandaa @ZooeyMiller Did this PR ever get written/merged in? If not, I'm happy to write it. I was literally just looking for this functionality, although I expected it to be under the name |
@RobertFischer I never did write it! would be great to see a PR from you for it if you have the time as I still think it would be useful. |
Credits to @ZooeyMiller for the pull request :) |
Fixed by #880. |
since
isEmpty
just checks if the string's length is zero, it still returnstrue
given a string of only whitespace, which I feel, for most implementations is not what people need when checking if a string is empty.Perhaps implementing
.trim()
on the string before checking if it's empty is worthwhile? Perhaps, if the original behaviour is to be maintained, and not break existing code the function could look something like this:Would love to make a PR if this is deemed a worthwhile addition.
The text was updated successfully, but these errors were encountered: