📌 Description
src/shared/utils/validation.ts exposes validateUrl, validateEmail, validateRepoName, and validateRequired. validateUrl requires a dot in the hostname (rejecting localhost/IP), and validateEmail uses a simplistic regex that rejects many valid addresses. Edge cases are not all tested.
💡 Why it matters: Over-strict validators block legitimate input; under-strict ones admit bad input.
🧩 Requirements and context
- Make
validateUrl accept valid hosts (localhost/IP) where appropriate while still rejecting non-http(s) schemes (e.g. javascript:).
- Improve
validateEmail to a sounder pattern without becoming catastrophically backtracking.
- Add tests covering the corrected and rejected cases for all four validators.
- Document each regex with a comment.
Non-functional requirements
- Must be secure, tested, and documented.
- Should be efficient and easy to review.
🛠️ Suggested execution
1. Fork the repo and create a branch
git checkout -b fix/validation-edge-cases
2. Implement changes
- Write/modify the relevant source:
src/shared/utils/validation.ts
- Write comprehensive tests:
src/shared/utils/validation.test.ts
- Add documentation: inline regex comments + TSDoc
- Include TSDoc doc comments
- Validate security assumptions: reject
javascript:/data: URLs; avoid ReDoS
3. Test and commit
- Cover edge cases: localhost URL, IP URL, dangerous scheme, plus-tagged email
- Include test output and security notes in the PR description.
Example commit message
fix(validation): correct URL/email rules + edge-case tests
✅ Acceptance criteria
🔒 Security notes
Reject javascript:/data: schemes; ensure regexes are not exponential-time.
📋 Guidelines
- Minimum 95% test coverage
- Clear documentation
- Timeframe: 96 hours
📌 Description
src/shared/utils/validation.tsexposesvalidateUrl,validateEmail,validateRepoName, andvalidateRequired.validateUrlrequires a dot in the hostname (rejecting localhost/IP), andvalidateEmailuses a simplistic regex that rejects many valid addresses. Edge cases are not all tested.🧩 Requirements and context
validateUrlaccept valid hosts (localhost/IP) where appropriate while still rejecting non-http(s) schemes (e.g.javascript:).validateEmailto a sounder pattern without becoming catastrophically backtracking.Non-functional requirements
🛠️ Suggested execution
1. Fork the repo and create a branch
2. Implement changes
src/shared/utils/validation.tssrc/shared/utils/validation.test.tsjavascript:/data:URLs; avoid ReDoS3. Test and commit
npm run testExample commit message
✅ Acceptance criteria
validateUrlaccepts localhost/IP, rejects dangerous schemesvalidateEmailaccepts common valid forms🔒 Security notes
Reject
javascript:/data:schemes; ensure regexes are not exponential-time.📋 Guidelines