fix: normalize hyphens in kebabcase - #13796
Conversation
The `RE_SPECIAL` regular expression in `@stdlib/string/base/kebabcase` omitted the hyphen, unlike the equivalent `snakecase`, `camelcase`, and `constantcase` implementations. As a result, inputs mixing hyphens and whitespace produced runs of hyphens, e.g. `kebabcase( 'foo - bar' )` returned `'foo---bar'` instead of `'foo-bar'`, and `'foo--bar'` was left unchanged. Add the hyphen to `RE_SPECIAL` so hyphens are treated as word separators and collapsed like the other cases. Adds regression tests.
|
👋 Hi there! 👋 And thank you for opening your first pull request! We will review it shortly. 🏃 💨 Getting Started
Next Steps
Running Tests LocallyYou can use # Run tests for all packages in the math namespace:
make test TESTS_FILTER=".*/@stdlib/math/.*"
# Run benchmarks for a specific package:
make benchmark BENCHMARKS_FILTER=".*/@stdlib/math/base/special/sin/.*"If you haven't heard back from us within two weeks, please ping us by tagging the "reviewers" team in a comment on this PR. If you have any further questions while waiting for a response, please join our Zulip community to chat with project maintainers and other community members. We appreciate your contribution! Documentation Links |
|
Hello! Thank you for your contribution to stdlib. We noticed that the contributing guidelines acknowledgment is missing from your pull request. Here's what you need to do:
This acknowledgment confirms that you've read the guidelines, which include:
We can't review or accept contributions without this acknowledgment. Thank you for your understanding and cooperation. We look forward to reviewing your contribution! |
Description
This pull request:
@stdlib/string/base/kebabcaseto normalize hyphens. TheRE_SPECIALregular expression omitted the hyphen, unlike the equivalentsnakecase,camelcase, andconstantcaseimplementations. As a result, inputs mixing hyphens and whitespace produced runs of hyphens:kebabcase( 'foo - bar' )returned'foo---bar'instead of'foo-bar', and'foo--bar'was left unchanged. Adding the hyphen toRE_SPECIALmakes hyphens behave as word separators and collapse consistently with the other case utilities. The non-base@stdlib/string/kebabcasedelegates to this implementation, so it is fixed as well.Related Issues
None.
Questions
No.
Other
All existing
kebabcasetests still pass; added regression tests for'foo - bar'and'foo--bar'.Checklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?
Disclosure
AI assistance was used only to cross-verify my work for mistakes; the fix and the regression tests were authored by me.
@stdlib-js/reviewers