Skip to content

Conversation

@Hugo-RM
Copy link
Contributor

@Hugo-RM Hugo-RM commented Jan 17, 2026

Fixes #3761
Fixes #3762

Changes

  • Fixes bug where p5Versions containing objects caused URL version parsing to fail
  • Migrates parseUrlParams and test file to TypeScript

Testing

  • Added tests for version patterns
  • Verified invalid inputs properly fall back to defaults
  • Tests use regex assertions and validity checks to ensure only valid versions are returned

Testing Strategy Note

The version parsing tests use regex patterns (e.g., /^1\.\d+\.\d+$/) rather than hardcoded expected versions (e.g., '1.11.11'). This approach:

  • Validates that the correct version prefix is returned
  • Verifies the result is a valid version from p5VersionStrings
  • Avoids test failures when new p5.js versions are released

Alternative approach: Tests could assert exact versions (e.g., expect(result.version).toBe('1.11.11')), which would catch sorting bugs but require updates whenever p5Versions changes.

Sorting bugs are very unlikely to occur unless version numbers change drastically. Current tests simply attempt to prevent future silent errors.

I'm happy to switch to hardcoded assertions or explore other testing strategies if you have suggestions!

I have verified that this pull request:

  • has no linting errors (npm run lint)
  • has no test errors (npm run test)
  • has no typecheck errors (npm run typecheck)
  • is from a uniquely-named feature branch and is up to date with the develop branch.
  • is descriptively named and links to an issue number, i.e. Fixes #123
  • meets the standards outlined in the accessibility guidelines

Updated parseVersionString to handle object format instead of
assuming string format.
- Add regression tests for major/major.minor version patterns
- Add tests for invalid input fallback behavior
- Migrate test file to TypeScript
- Export p5VersionStrings from parseUrlParams for test validation
- Use regex assertions to avoid breaking when p5Versions updates
@welcome
Copy link

welcome bot commented Jan 17, 2026

🎉 Thanks for opening this pull request! Please check out our contributing guidelines if you haven't already.

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.

URL version parsing fails for major/major.minor patterns Migrate Version URL Parser to TypeScript

1 participant