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

Leading underscores and dashes not respected. #25

Open
thoughtmanifest opened this issue Jan 13, 2015 · 2 comments
Open

Leading underscores and dashes not respected. #25

thoughtmanifest opened this issue Jan 13, 2015 · 2 comments

Comments

@thoughtmanifest
Copy link

Any string that starts with an underscore or dash has the underscore or dash removed in the result.

ex:
(->kebab-case "_my_string") => "my-string"
(->kebab-case "-my-string") => "my-string"

ex of NullPointerException:
(->kebab-case "-") =throws=> NullPointerException java.lang.NullPointerException
(->kebab-case "_") =throws=> NullPointerException java.lang.NullPointerException

This is also true for any number of dashes or underscores:
(->kebab-case "__----__----") =throws=> NullPointerException java.lang.NullPointerException

Also, empty strings throw the same exception:
(csk/->kebab-case "") =throws=> NullPointerException java.lang.NullPointerException

Since they all send nil to clojure.string/lower-case instead of empty string or leaving the dashes and underscores intact

@qerub
Copy link
Collaborator

qerub commented Jan 13, 2015

The exception issue is solved in master.

A workaround for (->kebab-case "-my-string") => "my-string" is to provide an extra :splitter \- argument after I've merged #23.

Let me think a bit about what the default behavior should be…

What would you expect (->kebab-case "-_ f") to return?

@thoughtmanifest
Copy link
Author

I suppose my expectation would be for it to honor all instances of the dash and replace all underscores with a dash and any number of consecutive whitespace with a single dash.

"-_ f" => "--f"
"---___   f" => "------f"
"___   f   ---   f" => "---f---f"

This should hold true for keywords as well.

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