Skip to content

feat!: put the lowercase argument first in str_starts_with and str_index_of - #320

Merged
bartveneman merged 2 commits into
mainfrom
claude/festive-shannon-2eh46a
Oct 21, 2026
Merged

bartveneman merged 2 commits into
mainfrom
claude/festive-shannon-2eh46a

Conversation

@bartveneman

Copy link
Copy Markdown
Member

Summary

str_starts_with and str_index_of now take the lowercase argument first, matching str_equals(lowercase, str). All three string helpers now share the same argument order. The README no longer carries the "this inconsistency will be fixed" note.

str_equals_range is unchanged.

Breaking changes

Function Before After
str_starts_with str_starts_with(str, prefix) str_starts_with(prefix, str)
str_index_of str_index_of(str, searchChar) str_index_of(searchChar, str)

Both are exported from the package root and from @projectwallace/css-parser/string-utils.

Migration steps (for the changelog)

The old and new signatures are both (string, string), so TypeScript will not flag callers that still use the old order. Update every call site by hand.

  1. Search your code for str_starts_with( and str_index_of(.
  2. Swap the two arguments so the lowercase string comes first:
-str_starts_with('WEBKIT-transform', 'webkit') // true
+str_starts_with('webkit', 'WEBKIT-transform') // true

-str_index_of('background-COLOR', 'color') // 11
+str_index_of('color', 'background-COLOR') // 11
  1. Remember that the first argument must be lowercase. Behavior is otherwise unchanged: matching is still case-insensitive on the second argument.
  2. str_equals already used this order, so it needs no change.

Test plan

  • pnpm exec tsc --noEmit
  • pnpm test --run (1496 passed)

Generated by Claude Code

…dex_of

Matches str_equals(lowercase, str).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Package Size Increase

📦 Package 📏 Base Size 📏 Source Size 📈 Size Change
@projectwallace/css-parser 47.4 kB 47.5 kB +153 B

@pkg-pr-new

pkg-pr-new Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@projectwallace/css-parser@2aa30b9

commit: 2aa30b9

@bartveneman
bartveneman merged commit 43c2d85 into main Oct 21, 2026
16 checks passed
@bartveneman
bartveneman deleted the claude/festive-shannon-2eh46a branch October 21, 2026 17:17
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