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

🐛 Fix correctTerm breaking hyphenated terms #10

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

a-tokyo
Copy link

@a-tokyo a-tokyo commented Jan 31, 2025

The bug is caused by the correctTerm function in the TitleCaserUtils class. It uses delimiters.source.charAt(0) to join the parts after splitting the word. When using the default delimiter regex /[-']/, delimiters.source.charAt(0) returns "[" instead of the expected hyphen or apostrophe. The solution was to determine the correct joiner based on whether the original word includes a hyphen or an apostrophe. This change has been applied in the updated minified code.

Before the fix, e-commerce resulted in E[commerce

Closes #9

The bug is caused by the `correctTerm` function in the TitleCaserUtils class. It uses `delimiters.source.charAt(0)` to join the parts after splitting the word. When using the default delimiter regex `/[-']/`, `delimiters.source.charAt(0)` returns `"["` instead of the expected hyphen or apostrophe. The solution was to determine the correct joiner based on whether the original word includes a hyphen or an apostrophe. This change has been applied in the updated minified code.
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

Successfully merging this pull request may close these issues.

🐛 Incorrect Title Formatting for Hyphenated and Apostrophe Words
1 participant