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 capitalizing words that start with numbers #346

Merged
merged 2 commits into from
Sep 13, 2024

Conversation

v-fernandez
Copy link
Contributor

Fix issue where words that start with numbers have the first non-numeric character capitalized incorrectly. Previously "1st" was being capitalized as "1St".

Fix issue where words like "1st" and "2nd" were capitalized as "1St" and "2Nd"
@@ -4,6 +4,7 @@ const IS_MANUAL_CASE = /\p{Ll}(?=[\p{Lu}])/u; // iPhone, iOS, etc.
const ALPHANUMERIC_PATTERN = /\p{Alphabetic}+/gu;
const IS_ACRONYM =
/^(\P{Alphabetic})*(?:\p{Alphabetic}\.){2,}(\P{Alphabetic})*$/u;
const IS_DIGIT = /\d/u;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you change alphanumeric pattern instead? I think the bug is that it should consider numbers words too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@blakeembrey I've update the pattern and removed the check for a numeric digit I had added previously.

Thanks for taking the time to review this PR.

@@ -1,7 +1,7 @@
const TOKENS = /(\S+)|(.)/g;
const IS_SPECIAL_CASE = /[\.#]\p{Alphabetic}/u; // #tag, example.com, etc.
const IS_MANUAL_CASE = /\p{Ll}(?=[\p{Lu}])/u; // iPhone, iOS, etc.
const ALPHANUMERIC_PATTERN = /\p{Alphabetic}+/gu;
const ALPHANUMERIC_PATTERN = /[\p{Alphabetic}\p{Nd}]+/gu;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any concerns with just doing \p{N}?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No concerns with changing to \p{N}

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@blakeembrey
Copy link
Owner

Thanks for the catch, embarrassed I didn't have a test for this 😅

@blakeembrey blakeembrey merged commit 976fa36 into blakeembrey:main Sep 13, 2024
2 checks passed
renovate bot referenced this pull request in JoshuaKGoldberg/emoji-platform-data Sep 18, 2024
This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
|
[title-case](https://redirect.github.com/blakeembrey/change-case/tree/master/packages/title-case#readme)
([source](https://redirect.github.com/blakeembrey/change-case)) |
[`4.3.1` ->
`4.3.2`](https://renovatebot.com/diffs/npm/title-case/4.3.1/4.3.2) |
[![age](https://developer.mend.io/api/mc/badges/age/npm/title-case/4.3.2?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/title-case/4.3.2?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/title-case/4.3.1/4.3.2?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/title-case/4.3.1/4.3.2?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>blakeembrey/change-case (title-case)</summary>

###
[`v4.3.2`](https://redirect.github.com/blakeembrey/change-case/releases/tag/title-case%404.3.2)

[Compare
Source](https://redirect.github.com/blakeembrey/change-case/compare/[email protected])

**Fixed**

- Fix capitalization of words that start with a number
[https://github.com/blakeembrey/change-case/pull/346](https://redirect.github.com/blakeembrey/change-case/pull/346)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR was generated by [Mend Renovate](https://mend.io/renovate/).
View the [repository job
log](https://developer.mend.io/github/JoshuaKGoldberg/emoji-platform-data).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOC44MC4wIiwidXBkYXRlZEluVmVyIjoiMzguODAuMCIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiZGVwZW5kZW5jaWVzIl19-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
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.

2 participants