-
Notifications
You must be signed in to change notification settings - Fork 66
feat: add X (Twitter) deep link support #25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
608f32a
9735cfa
84709a7
f2edcef
1041d0d
3dcc22a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,7 +12,7 @@ | |
| "devDependencies": { | ||
| "@typescript-eslint/eslint-plugin": "^8.50.0", | ||
| "@typescript-eslint/parser": "^8.50.0", | ||
| "eslint": "^9.39.2", | ||
| "eslint": "^8.57.1", | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: cat package.json | head -50Repository: 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 |
||
| "eslint-config-prettier": "^10.1.8", | ||
| "husky": "^9.1.7", | ||
| "lint-staged": "^16.2.7", | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,7 @@ | ||
| import { linkedinHandler } from "./linkedin"; | ||
| import { unknownHandler } from "./unknown"; | ||
| import { youtubeHandler } from "./youtube"; | ||
| import { instagramHandler } from "./instagram"; | ||
| import { linkedinHandler } from './linkedin'; | ||
| import { unknownHandler } from './unknown'; | ||
| import { youtubeHandler } from './youtube'; | ||
| import { instagramHandler } from './instagram'; | ||
| import { xHandler } from './x'; | ||
|
|
||
| export { | ||
| linkedinHandler, | ||
| youtubeHandler, | ||
| instagramHandler, | ||
| unknownHandler | ||
| } | ||
| export { linkedinHandler, youtubeHandler, instagramHandler, unknownHandler, xHandler }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| import { DeepLinkHandler } from '../types'; | ||
|
|
||
| export const xHandler: DeepLinkHandler = { | ||
| match: (url) => url.match(/https?:\/\/(?:www\.)?x\.com\/([^/?]+)/), | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 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`);
});
EOFRepository: 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 -20Repository: mdsaban/universal-app-opener Length of output: 145 🏁 Script executed: cat -n ./packages/core/src/platforms/x.tsRepository: mdsaban/universal-app-opener Length of output: 618 Ensure the regex pattern restricts to X profile URLs only. The current regex Since X usernames are limited to 1–15 characters and contain only letters, numbers, and underscores, tighten the pattern to 🤖 Prompt for AI Agents |
||
|
|
||
| build: (webUrl, match) => { | ||
| const username = match[1]; | ||
|
|
||
| return { | ||
| webUrl, | ||
| ios: `x://user?screen_name=${username}`, | ||
| android: `intent://user?screen_name=${username}#Intent;scheme=x;package=com.twitter.android;end`, | ||
| platform: 'x', | ||
| }; | ||
| }, | ||
| }; | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 inpackages/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
📝 Committable suggestion
🤖 Prompt for AI Agents