Validate stored profile links#101
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthroughIntroduces link validation logic for the user profile update endpoint ( Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant Endpoint as API Handler
participant Validator as Link Validator
participant Database
Client->>Endpoint: PATCH /api/users/me<br/>(with link field)
Endpoint->>Validator: Validate & normalize link
alt Valid URL or null
Validator->>Validator: Trim input
Validator-->>Endpoint: Return normalized link
Endpoint->>Database: Update profile with link
Database-->>Endpoint: Success
Endpoint-->>Client: 200 OK
else Invalid/Malformed URL
Validator-->>Endpoint: Validation error
Endpoint-->>Client: 400 Bad Request<br/>(error message)
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Review rate limit: 0/1 reviews remaining, refill in 60 minutes.Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
apps/web/app/api/users/me/route.ts (1)
28-49: ⚡ Quick winConsolidate URL validation policy into a shared helper.
This logic overlaps with
apps/web/app/api/company-suggestions/route.ts:6-17; centralizing URL validation would reduce drift between endpoints and keep protocol/format rules consistent.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/web/app/api/users/me/route.ts` around lines 28 - 49, The URL validation in normalizeProfileLink duplicates logic used elsewhere; extract the validation into a shared helper (e.g., create a new function validateHttpUrl or normalizeUrl in a common utilities module) and replace normalizeProfileLink's internal validation with a call to that helper, then update the other duplicate site (the logic in apps/web/app/api/company-suggestions/route.ts) to use the same helper; ensure the helper returns the normalized string or null and preserves the same error messages/behavior for non-string, empty, invalid, and non-http(s) protocols so callers like normalizeProfileLink can simply delegate.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@apps/web/app/api/users/me/route.ts`:
- Around line 28-49: The URL validation in normalizeProfileLink duplicates logic
used elsewhere; extract the validation into a shared helper (e.g., create a new
function validateHttpUrl or normalizeUrl in a common utilities module) and
replace normalizeProfileLink's internal validation with a call to that helper,
then update the other duplicate site (the logic in
apps/web/app/api/company-suggestions/route.ts) to use the same helper; ensure
the helper returns the normalized string or null and preserves the same error
messages/behavior for non-string, empty, invalid, and non-http(s) protocols so
callers like normalizeProfileLink can simply delegate.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 31c53f40-5b64-4e53-a2f8-510f94804e4c
📒 Files selected for processing (2)
apps/web/__tests__/api/profile.test.tsapps/web/app/api/users/me/route.ts
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. 🤖 Generated with Claude Code - If this code review was useful, please react with 👍. Otherwise, react with 👎. |
|
Merged. Adds server-side |
Summary
Verification
Summary by CodeRabbit
New Features
Tests