Skip to content

Conversation

@simon-kepplinger
Copy link

@simon-kepplinger simon-kepplinger commented Jan 26, 2026

Hello,

Just came across an issue when using the analytics script: the name and image in DubAnalytics.partner were URL-encoded. This broke my UI when displaying those values.

Looking through the script, it seems this happens because the values are URL-encoded before being stored in the dub_partner_data cookie, but aren’t decoded again when the cookie is read in init().

This PR is just a proposal/draft with a minimal change: decode partner.name and partner.image after JSON.parse before assigning them back to DubAnalytics. I only did basic manual testing, but it fixes the issue on my end.

Let me know what you think.

Summary by CodeRabbit

  • Bug Fixes
    • Fixed improper handling of partner names and images containing special characters or URL-encoded values when retrieved from cookies. These values are now correctly decoded with safety checks before use, ensuring partner information displays properly throughout the application instead of showing raw encoded text.

✏️ Tip: You can customize this high-level summary in your review settings.

`trackClick` stores `partner.name` / `partner.image` URL-encoded in the
cookie, so we should decode those fields when hydrating from it in
`init`. Otherwise `DubAnalytics.partner` can end up containing URL-encoded
name/image values.
@vercel
Copy link

vercel bot commented Jan 26, 2026

@simon-kepplinger is attempting to deploy a commit to the Dub Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link

coderabbitai bot commented Jan 26, 2026

📝 Walkthrough

Walkthrough

A helper function safeDecodeURIComponent is introduced to decode URL-encoded partner metadata (name and image) extracted from the dub_partner_data cookie during parsing, with existence checks guarding the decoding operations.

Changes

Cohort / File(s) Summary
Cookie partner metadata decoding
packages/script/src/base.js
Adds safeDecodeURIComponent helper function and applies URL decoding to partner.name and partner.image fields during dub_partner_data cookie parsing, with existence checks before decoding

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 Cookies once wrapped in percent-encoded strands,
Now decode with grace through our helper's gentle hands,
Partner names and images sparkle anew,
A rabbit approves—this fix will surely do! 🍪

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Fix URL-encoded partner fields when reading dub_partner_data cookie' directly and accurately summarizes the main change: decoding URL-encoded partner.name and partner.image fields from the dub_partner_data cookie.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

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

Comment @coderabbitai help to get the list of available commands and usage tips.

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.

1 participant