Skip to content

fix: normalize uppercase version prefix and harden version resolve lookup#62

Merged
ben-miru merged 1 commit into
mainfrom
claude/hunt-setup-cli-H9LoF
May 17, 2026
Merged

fix: normalize uppercase version prefix and harden version resolve lookup#62
ben-miru merged 1 commit into
mainfrom
claude/hunt-setup-cli-H9LoF

Conversation

@miru-agents

Copy link
Copy Markdown
Collaborator

Summary

Fixes two correctness issues in src/versions.ts surfaced by a /hunt scan of src/:

  • sanitize() — case-sensitive v strip: version.replace(/^v/, '') only removed a lowercase v, so an input like V1.2.3 became vV1.2.3, producing an invalid release tag and a 404 download URL. Now uses /^v/i so V1.2.3v1.2.3. Empty/whitespace/latest behavior is unchanged.
  • resolve() — prototype-chain lookup: mappings[version] || version read through Object.prototype, so a version string equal to an inherited key (toString, constructor, hasOwnProperty) returned an inherited value instead of the input. Now uses Object.hasOwn(mappings, version) so such inputs pass through unchanged. Currently latent (sanitize prefixes v), fixed defensively.

dist/ bundle rebuilt (npm run package) to stay in sync with src/.

Test plan

  • Extended __tests__/versions.test.ts: uppercase V prefix normalization (V1.2.3, V0.9.0 ) and prototype-key passthrough (toString, constructor, hasOwnProperty)
  • npm test — 41/41 passed, 3/3 suites, 100% coverage on versions.ts
  • npm run lint (eslint) — clean
  • npm run format:check (prettier) — clean
  • Verified rebuilt dist/index.js contains the fixed code

https://claude.ai/code/session_01SiiCitU5rTuvXvNGmMLzmP


Generated by Claude Code

…okup

sanitize() now strips a leading v/V case-insensitively so inputs like
"V1.2.3" resolve to a valid release tag instead of "vV1.2.3".

resolve() now uses Object.hasOwn for the mappings lookup so a version
string matching an inherited Object.prototype key (e.g. "toString",
"constructor") is passed through unchanged instead of returning an
inherited value.

https://claude.ai/code/session_01SiiCitU5rTuvXvNGmMLzmP
@ben-miru ben-miru merged commit 9f47df5 into main May 17, 2026
27 checks passed
@ben-miru ben-miru deleted the claude/hunt-setup-cli-H9LoF branch May 17, 2026 21:57
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.

3 participants