Skip to content

Conversation

@shubham-guptaaa
Copy link

@shubham-guptaaa shubham-guptaaa commented Dec 21, 2025

Summary

This pull request introduces deep link support for the X (Twitter) platform within the Universal App Opener core package.

Changes Included

  • Added new x.ts handler to generate deep links for X profiles.
  • Updated index.ts to register the X handler.
  • Updated types.ts to extend deep link result types for X.
  • Modified demo app to test and validate X deep linking.
  • No breaking changes; existing platforms remain unaffected.

Deep Link Behavior

  • iOS: x://user?screen_name=<username>
  • Android: intent://user?screen_name=<username>#Intent;scheme=x;package=com.twitter.android;end
  • Desktop: falls back to the original web URL.

Motivation

This enhancement expands platform compatibility and allows users to open X links directly in the mobile app, improving user experience and feature coverage.

Testing

  • Verified deep linking on Android via browser intent.
  • Verified fallback behavior when app is not installed.
  • Verified URL matching using regex patterns.
  • Demo app updated for manual validation.

Notes

No breaking changes. Safe to merge.

Summary by CodeRabbit

  • New Features
    • Added support for X (Twitter) profile deep links on iOS and Android platforms
    • Included example X profile link in the demo section

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

@coderabbitai
Copy link

coderabbitai bot commented Dec 21, 2025

Walkthrough

X (Twitter) deep link support is introduced to the deep link handler system. A new xHandler is implemented to match and build deep links for X profile URLs, wired into the core handler registry, exported from the platforms module, the Platform type is expanded to include 'x', and a demo UI example link is added.

Changes

Cohort / File(s) Summary
Type Definitions
packages/core/src/types.ts
Added 'x' literal to the Platform type union alongside existing platforms (youtube, linkedin, instagram, unknown)
X Handler Implementation
packages/core/src/platforms/x.ts
New file introducing xHandler of type DeepLinkHandler that matches Twitter/X profile URLs via regex and builds platform-specific deep links (x:// for iOS, intent:// for Android) with fallback to web URL
Handler Exports
packages/core/src/platforms/index.ts
Added import and public export of xHandler to the platforms module's public API
Core Handler Integration
packages/core/src/index.ts
Added xHandler to the barrel import from ./platforms and included it in the internal handlers array for deep link generation
Demo UI
apps/demo/index.html
Added new example link "X Profile" with 🆇 icon and data-url="https://x.com/" in the Try Example Links section
Dependency Update
package.json
Downgraded devDependency eslint from ^9.39.2 to ^8.57.1

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

  • packages/core/src/platforms/x.ts: Verify regex pattern correctly matches X profile URLs and that the intent URI structure for Android is properly formatted
  • packages/core/src/types.ts: Confirm the Platform type change propagates correctly to all handler implementations
  • Eslint downgrade rationale: Verify the reason for reverting eslint to an older version and ensure no breaking changes from the newer version

Poem

🐰 A new platform hops on board,
X deep links we now afford!
From tweet to app with regex grace,
Android and iOS find their place,
The handlers dance in harmony! 🎭

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ 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 clearly and concisely summarizes the main change: adding X (Twitter) deep link support to the codebase, which is reflected in all modified files.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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

Copy link

@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: 3

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9d51def and 3dcc22a.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (6)
  • apps/demo/index.html (1 hunks)
  • package.json (1 hunks)
  • packages/core/src/index.ts (2 hunks)
  • packages/core/src/platforms/index.ts (1 hunks)
  • packages/core/src/platforms/x.ts (1 hunks)
  • packages/core/src/types.ts (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
packages/core/src/platforms/x.ts (1)
packages/core/src/types.ts (1)
  • DeepLinkHandler (10-13)
packages/core/src/index.ts (2)
packages/core/src/platforms/index.ts (4)
  • youtubeHandler (7-7)
  • linkedinHandler (7-7)
  • instagramHandler (7-7)
  • xHandler (7-7)
packages/core/src/platforms/instagram.ts (1)
  • instagramHandler (3-17)
🔇 Additional comments (6)
packages/core/src/types.ts (1)

1-1: LGTM!

The Platform type is correctly extended to include the new 'x' literal, enabling type-safe recognition of X/Twitter as a supported platform.

packages/core/src/index.ts (2)

1-7: LGTM!

The import statement is properly updated to include xHandler from the platforms module, maintaining alphabetical ordering within the destructured imports.


12-12: LGTM!

The xHandler is correctly added to the handlers array, enabling X/Twitter URL matching in the generateDeepLink function. The handler placement at the end of the array is appropriate since handler order determines matching priority.

packages/core/src/platforms/index.ts (2)

5-5: LGTM!

The xHandler import follows the established pattern for platform handlers.


7-7: LGTM!

The xHandler is properly exported alongside existing handlers, making it available for external consumption via the public API.

packages/core/src/platforms/x.ts (1)

11-12: iOS deep link scheme should use twitter:// instead of x://; Android package name is correct.

The official X Developer documentation specifies the iOS URL scheme as twitter://user?id=12345, not x://. The code currently uses x://user?screen_name= which deviates from documented schemes. Additionally, the documented format uses a numeric ID parameter rather than screen_name.

The Android package name com.twitter.android remains correct and unchanged after rebranding, so that part of the implementation is confirmed.

Recommend updating the iOS scheme to match official documentation or testing the current x:// scheme to confirm it works on recent X app versions, as there's no official documentation for the x:// protocol.

Comment on lines +38 to +41
<a href="#" class="example-link x-link" data-url="https://x.com/">
<span class="link-icon">🆇</span>
<span class="link-text">X Profile</span>
</a>
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

The demo URL is incomplete and won't match the handler regex.

The X Profile example link uses data-url="https://x.com/" which is missing a username. The xHandler regex in packages/core/src/platforms/x.ts (Line 4) expects a username: /https?:\/\/(?:www\.)?x\.com\/([^/?]+)/. This URL will fail to match and won't generate deep links when clicked in the demo.

🔎 Proposed fix: add a sample username
-          <a href="#" class="example-link x-link" data-url="https://x.com/">
+          <a href="#" class="example-link x-link" data-url="https://x.com/elonmusk">
             <span class="link-icon">🆇</span>
             <span class="link-text">X Profile</span>
           </a>
📝 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
<a href="#" class="example-link x-link" data-url="https://x.com/">
<span class="link-icon">🆇</span>
<span class="link-text">X Profile</span>
</a>
<a href="#" class="example-link x-link" data-url="https://x.com/elonmusk">
<span class="link-icon">🆇</span>
<span class="link-text">X Profile</span>
</a>
🤖 Prompt for AI Agents
In apps/demo/index.html around lines 38 to 41, the X Profile example uses
data-url="https://x.com/" which lacks a username and therefore won't match the
xHandler regex; update the data-url to include a sample username (e.g.
data-url="https://x.com/sampleuser") so the regex
/https?:\/\/(?:www\.)?x\.com\/([^/?]+)/ will match and deep links are generated
when the demo link is clicked.

"@typescript-eslint/eslint-plugin": "^8.50.0",
"@typescript-eslint/parser": "^8.50.0",
"eslint": "^9.39.2",
"eslint": "^8.57.1",
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

cat package.json | head -50

Repository: mdsaban/universal-app-opener

Length of output: 909


Justify the ESLint version downgrade to ^8.57.1.

The version range of ESLint currently supported by @typescript-eslint is ^8.57.0 || ^9.0.0. The downgrade from ^9.39.2 to ^8.57.1 is not required for compatibility with @typescript-eslint v8.50.0 and appears unrelated to adding X deep link support. If this change is intentional (e.g., due to configuration migration constraints or other reasons), please document the justification in the PR description.

🤖 Prompt for AI Agents
In package.json around line 15, the ESLint version was downgraded to "eslint":
"^8.57.1" without justification; either revert the package.json change back to
the previous version (e.g., ^9.39.2) to preserve compatibility, or keep the
downgrade but add a clear justification to the PR description explaining why
^8.57.1 is required (compatibility constraint, config migration, CI/tooling
reasons, etc.); update the package.json only if necessary to match the justified
version and ensure it remains compatible with @typescript-eslint's supported
range.

import { DeepLinkHandler } from '../types';

export const xHandler: DeepLinkHandler = {
match: (url) => url.match(/https?:\/\/(?:www\.)?x\.com\/([^/?]+)/),
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# First, let's run the provided test script
node << 'EOF'
const regex = /https?:\/\/(?:www\.)?x\.com\/([^/?]+)/;

const testUrls = [
  "https://x.com/elonmusk",
  "https://www.x.com/elonmusk",
  "http://x.com/elonmusk",
  "https://x.com/elonmusk/",
  "https://x.com/elonmusk?some=param",
  "https://x.com/elonmusk/status/123456",
  "https://x.com/i/flow/login",
  "https://x.com/home",
  "https://x.com/explore"
];

console.log("Testing X URL regex pattern:\n");
testUrls.forEach(url => {
  const match = url.match(regex);
  console.log(`URL: ${url}`);
  console.log(`Match: ${match ? match[1] : 'NO MATCH'}\n`);
});
EOF

Repository: mdsaban/universal-app-opener

Length of output: 522


🏁 Script executed:

# Then check the file structure and location
find . -name "*.ts" -type f | grep -i "platform.*x\|x.*platform" | head -20

Repository: mdsaban/universal-app-opener

Length of output: 145


🏁 Script executed:

cat -n ./packages/core/src/platforms/x.ts

Repository: mdsaban/universal-app-opener

Length of output: 618


Ensure the regex pattern restricts to X profile URLs only.

The current regex /https?:\/\/(?:www\.)?x\.com\/([^/?]+)/ is too permissive. It matches and extracts values from non-profile URLs like x.com/i/flow/login, x.com/home, and x.com/explore, returning "i", "home", and "explore" respectively as usernames. These invalid values are then passed to the deep link builder, likely causing failures.

Since X usernames are limited to 1–15 characters and contain only letters, numbers, and underscores, tighten the pattern to /https?:\/\/(?:www\.)?x\.com\/([a-zA-Z0-9_]+)(?:\/|$|\?)/ or add a negative lookahead to exclude known non-profile paths like /status/, /i/, /home, /explore, etc.

🤖 Prompt for AI Agents
In packages/core/src/platforms/x.ts around line 4, tighten the URL matcher so it
only captures valid X profile usernames: restrict the captured segment to 1–15
characters consisting of letters, digits and underscores, and require a trailing
slash, end-of-string or query delimiter (or alternatively add a negative
lookahead to exclude known non-profile segments like "i", "home", "explore",
"status", etc.); update the match implementation accordingly so non-profile
paths no longer produce a fake username.

@tanmoyPaul12
Copy link
Contributor

@mdsaban This Twitter handler looks the most solid so far compared to the others.
Changing the regex to something like: /https?://(?:www.)?x.com/([a-zA-Z0-9_]+)(?:/|$|?)/
Would tighten it .

Also, the changes to index.html, package.json, and pnpm-lock.yaml don’t seem necessary for the handler reverting them would keep the PR more focused.

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