Skip to content

feat: validate style IDs in style_comparison_tool#121

Merged
mattpodwysocki merged 5 commits into
mainfrom
fix/style-comparison-id-validation
Jun 23, 2026
Merged

feat: validate style IDs in style_comparison_tool#121
mattpodwysocki merged 5 commits into
mainfrom
fix/style-comparison-id-validation

Conversation

@mattpodwysocki

@mattpodwysocki mattpodwysocki commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Summary

  • before and after style inputs are now validated to only accept well-formed style identifiers
  • Validation is enforced at two layers: a Zod .regex() on the input schema (rejects bad input immediately on the way in) and a validateStyleId() check inside processStyleId() after the mapbox://styles/ prefix is stripped
  • Style IDs must match username/styleId where each segment is [a-zA-Z0-9_-] only; anything else is rejected with a descriptive error before any comparison URL is constructed
  • Two new test cases cover rejection of special characters in both bare and mapbox://styles/ prefixed inputs (14 tests total)

Test plan

  • npm test -- test/tools/style-comparison-tool/StyleComparisonTool.test.ts — 14 tests pass
  • Valid inputs (mapbox/streets-v12, mapbox://styles/mapbox/outdoors-v12, bare style ID with token) continue to work unchanged
  • Inputs containing HTML or other special characters are rejected with an "Invalid style format" error

🤖 Generated with Claude Code

mattpodwysocki and others added 4 commits April 1, 2026 14:16
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add input validation for the before/after style parameters to ensure
they contain only alphanumeric characters, hyphens, and underscores.
Validation is enforced at both the Zod schema layer and inside
processStyleId() after the mapbox://styles/ prefix is stripped, so
malformed style IDs are rejected with a descriptive error before any
comparison URL is constructed.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
@mattpodwysocki mattpodwysocki requested a review from a team as a code owner June 22, 2026 14:20
@mattpodwysocki mattpodwysocki merged commit fa7ddeb into main Jun 23, 2026
1 check passed
@mattpodwysocki mattpodwysocki deleted the fix/style-comparison-id-validation branch June 23, 2026 13:13
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