You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
By default it looks like the kebabCase function passes a string through the splitByCase function for it's underlying implementation. The functions type itself only takes .You can get around it if you need with a kebabCase(splitByCase('text to convert, [' '])) which adds the space as a joiner to the splitByCase function as it is not part of the default Splitter types. It could be added as default, but I suspect there are edge cases and side effects with whitespace that you might avoid by implementing this way instead of including spaces by default.
Thanks for the response. While I get your points about edge cases and side-effects and do appreciate the workaround, it is still a workaround.
I do think it is more likely that people will want to do kebab-case specifically with spaces as a default. This is the first example of a string conversion lib I've experienced where it is not a default, so it seems an odd choice not to default to converting spaces. (see https://github.com/az33zy/slugrace at https://slugrace.zy.ke/ )
Wouldn't most devs who specifically request a a string conversion to kebab, snake, camel, pascal or indeed any other expect the spaces to be removed as part of that conversion?
It's cool if not, but if not it probably should be documented behavior.
By default it looks like the kebabCase function passes a string through the splitByCase function for it's underlying implementation. The functions type itself only takes .You can get around it if you need with a kebabCase(splitByCase('text to convert, [' '])) which adds the space as a joiner to the splitByCase function as it is not part of the default Splitter types. It could be added as default, but I suspect there are edge cases and side effects with whitespace that you might avoid by implementing this way instead of including spaces by default.
Environment
Package 1.3.0
Node v21.7.3
Vue 3
Reproduction
Expect:
a-string-with-spaces
Actual:
a string with spaces
Describe the bug
Trying to convert a string into a slug for a URI and noticed this behaviour.
Additional context
I noticed the tests do not have test cases for string with spaces and wonder if this is intended behaviour.
Logs
No response
The text was updated successfully, but these errors were encountered: