fix(native): stop the deep-link mapper from dropping the URL fragment - #2584
Merged
Conversation
mapDeepLink built its result from pathname + search and never read parsed.hash, so every deep link lost its fragment entering the app. That breaks exactly one thing badly: a claim link carries its password in the fragment (#p=<password>) and deliberately never sends it to the server — peanut-link.utils.ts parses it client-side and claim.ts only relays a signature. So tapping a claim link with the app installed opened /claim?c=&v=&i= with no password: a claim page that cannot claim. sanitizeRedirectURL already preserved .hash, so the loss was here. Re-attach it once at the boundary, around an extracted mapDeepLinkPath, instead of in each of the six existing return points — a seventh is one route away and would silently reintroduce the bug.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
Contributor
Code-analysis diffPainscore total: 6739.08 → 6739.16 (+0.08) 🆕 New findings (6)
✅ Resolved (6)
|
Contributor
🧪 UI test report — ✅ all greenSuites
📊 Coverage (unit)
⏱ 10 slowest test cases
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
mapDeepLink()builds its result fromparsed.pathname+parsed.searchand never readsparsed.hash, so every deep link loses its fragment on the way into the native app.That matters for one link type in particular: a claim link's password lives in the fragment (
/claim?c=&v=&i=#p=<password>) and is deliberately never sent to the server —peanut-link.utils.tsparses it client-side andclaim.tsonly ever relays a signature. So today, tapping a claim link on a device with the app installed opens/claim?c=&v=&i=without the password: the page loads, and there is no way to claim from it.sanitizeRedirectURLalready preserves.hash, so the loss was entirely in this mapper.Fix
Re-attach the fragment once in
mapDeepLink, around a newmapDeepLinkPaththat keeps the existing branch logic untouched:Deliberately not appended inside each branch — there are six return points and a seventh is one route away. Doing it at the boundary is the only shape a future branch can't forget.
parsed.hashis''when absent (and for a bare trailing#), so no stray#is introduced.Behaviour is otherwise unchanged: off-host links still return
null, and malformed percent-escapes still degrade tonullvia the existing guard rather than throwing during render.Tests
Added to
src/utils/__tests__/native-routes.test.ts(there was no fragment coverage at all):/send/bob#p=x→/send?recipient=bob#p=x)#when the link has no fragmentNotes for reviewers
devandmainthat breaks warm claim links today, with or without deferred linking. Related to feat(native): deferred deep linking through the store install (TASK-20772) #2560; does not depend on it and is not depended on by it.paths: ["*"]for all three appIDs, sopeanut.me/invite?code=…routes into the app, but/inviteis stripped from the native build (scripts/native-build.js) and absent from the Android intent filter — on iOS that link dead-ends on a route that doesn't exist. Fixing it needs the invite code written to a cookie in the deep-link handler (useNativePlugins), not in this pure path mapper which runs during render, and that file overlaps feat(native): deferred deep linking through the store install (TASK-20772) #2560. Left for a follow-up so this PR stays a one-line behavioural change.