Skip to content

Conversation

FacuBozzi
Copy link
Contributor

one liner that fixes: https://www.notion.so/peanutprotocol/Feat-shorter-address-on-preview-21483811757980aab7bef5a6bb319567

social previews still have some work to do, but any changes/improvements are agnostic to this simple modification, so we can still merge it

Copy link

vercel bot commented Jun 17, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
peanut-ui ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 17, 2025 10:39pm

Copy link
Contributor

coderabbitai bot commented Jun 17, 2025

Walkthrough

The change updates the API route handler to import and use the printableAddress utility. It conditionally formats the username query parameter: if its length exceeds 12 characters, it is transformed using printableAddress; otherwise, it remains unchanged. No other logic or exported entity is modified.

Changes

Files Change Summary
src/app/api/og/route.tsx Imports printableAddress and uses it to conditionally format the username query parameter.

Possibly related PRs

Suggested reviewers

  • kushagrasarathe
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate Unit Tests
  • Create PR with Unit Tests
  • Post Copyable Unit Tests in Comment
  • Commit Unit Tests in branch feat/format-eth-social-preview

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai auto-generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c36610b and bad197f.

📒 Files selected for processing (1)
  • src/app/api/og/route.tsx (2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/app/api/og/route.tsx (1)
src/utils/general.utils.ts (1)
  • printableAddress (57-60)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Deploy-Preview
🔇 Additional comments (1)
src/app/api/og/route.tsx (1)

10-10: Verify barrel export path for printableAddress.

printableAddress lives in src/utils/general.utils.ts.
This import assumes that src/utils/index.ts (aliased as @/utils) re-exports it; otherwise the build will fail with “export not found”.
Please confirm the barrel is in place or import directly from @/utils/general.utils.

Comment on lines +48 to +51
const username =
searchParams.get('username')!.length > 12
? printableAddress(searchParams.get('username')!)
: searchParams.get('username')! // username will always exist. If it doesn't, page will 404 + format the length if its too long/an ethereum address
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Eliminate duplicate searchParams.get() calls and add null-safety.

searchParams.get('username') is invoked three times and is blindly asserted non-null (!).
A missing param would throw at runtime before your 404 logic can run.

-    const username =
-        searchParams.get('username')!.length > 12
-            ? printableAddress(searchParams.get('username')!)
-            : searchParams.get('username')!
+    const rawUsername = searchParams.get('username')
+    if (!rawUsername) {
+        return new NextResponse('Missing "username" query param', { status: 400 })
+    }
+    const username =
+        rawUsername.length > 12 ? printableAddress(rawUsername) : rawUsername

This removes redundant look-ups, guards against null, and keeps the formatting logic unchanged.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const username =
searchParams.get('username')!.length > 12
? printableAddress(searchParams.get('username')!)
: searchParams.get('username')! // username will always exist. If it doesn't, page will 404 + format the length if its too long/an ethereum address
const rawUsername = searchParams.get('username')
if (!rawUsername) {
return new NextResponse('Missing "username" query param', { status: 400 })
}
const username =
rawUsername.length > 12 ? printableAddress(rawUsername) : rawUsername
🤖 Prompt for AI Agents
In src/app/api/og/route.tsx around lines 48 to 51, the code calls
searchParams.get('username') multiple times and uses non-null assertions,
risking runtime errors if the parameter is missing. To fix this, store the
result of searchParams.get('username') in a variable once, check if it is null
before proceeding, and then apply the length check and formatting logic on this
variable. This eliminates redundant calls and adds null-safety while preserving
the existing behavior.

@jjramirezn jjramirezn merged commit 5307f3c into peanut-wallet-dev Jun 19, 2025
5 checks passed
@jjramirezn jjramirezn deleted the feat/format-eth-social-preview branch June 19, 2025 17:18
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