Skip to content

improvement(utils): share escapeRegExp, compareStrings and isRecordLike - #8052

Merged
waleedlatif1 merged 5 commits into
stagingfrom
consolidate/round-1
Sep 20, 2026
Merged

waleedlatif1 merged 5 commits into
stagingfrom
consolidate/round-1

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • Adds escapeRegExp, hasRegexMetacharacter and compareStrings to @sim/utils/string, and replaces the duplicated copies across apps and packages
  • escapeRegExp: 9 named copies plus 9 inline replace(/[.*+?^${}()|[\]\\]/g, '\\$&') bodies, spanning apps/sim, apps/desktop and packages/emcn. executor/constants no longer exports it, so tools/http/utils drops its only edge to that module
  • compareStrings: 7 identical copies in the secret-provenance and matcher code, plus the catalog cursor comparator that argued the same case in its own words
  • isRecordLike: adopts the helper @sim/utils/object already exported, replacing 8 identical local isRecord copies. ServiceNow keeps its domain-typed name but delegates the predicate
  • One character class now backs both the escaper and isPlainText's metacharacter test, which previously each declared their own
  • Documents all three in the CLAUDE.md and global-rule helper lists

No behavior changes: every removed body was character-identical to the shared one. Two copies are deliberately left alone — the Pi search one is source text injected into a sandbox and cannot import, and ts-sdk is published without a @sim/utils dependency.

Type of Change

  • Refactor / improvement

Testing

  • bun run type-check clean in apps/sim, apps/desktop, packages/{utils,emcn,sim-cli}
  • Targeted vitest over every touched area: 5,527 tests in apps/sim, 1,657 in desktop, 1,165 in sim-cli, 348 in emcn, 50 in utils (13 new, covering both helpers and their agreement with each other)
  • bun run lint, bun run check:audits (47/47), bun run test:scripts (351), check-block-registry, docs-manifest:check all pass

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

🤖 Generated with Claude Code

…haracter class

Replaces the nine inline copies of the escape body the name-based sweep missed,
folds the catalog cursor comparator into compareStrings, and gives linear-regex
its metacharacter test from the same source the escaper uses.
@vercel

vercel Bot commented Sep 20, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
docs Ready Ready Preview Sep 20, 2026 1:36am UTC

Request Review

@greptile-apps

greptile-apps Bot commented Sep 20, 2026

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

The PR appears safe to merge because the shared helpers preserve the removed implementations’ behavior and no dangling callers or rule violations remain.

Summary

This PR centralizes duplicated string and object utilities without changing their behavior.

  • Adds shared escapeRegExp, hasRegexMetacharacter, and compareStrings utilities with focused tests.
  • Replaces equivalent local regex escaping, string comparison, and record-guard implementations across applications and packages.
  • Removes the executor constants dependency from callers that only needed regex escaping.
  • Documents the preferred shared helpers in repository guidance.

Reviews (1) · Last reviewed commit: "improvement(utils): finish the escapeReg..."

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues found across 54 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Re-trigger cubic

@waleedlatif1
waleedlatif1 merged commit 812f130 into staging Sep 20, 2026
37 checks passed
@waleedlatif1
waleedlatif1 deleted the consolidate/round-1 branch September 20, 2026 01:52
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.

1 participant