@devries-cameron20 / t3code Mirror · read-only / commits / c17a469bb7
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 22, 09:30 UTC

fix(mobile): keep PRs readable when image URLs are malformed (#23466)

Co-authored-by: GPT-6.1 Sol <noreply@openai.com>

Victor Vogel committed Oct 31, 2026 at 03:35 UTC c17a469bb7f27e134807ce3be6724c57cd961059
2 files changed +30 -1
apps/mobile/src/features/pull-requests/pullRequestDescription.test.ts
+20
@@ -3,6 +3,26 @@ import { parseMarkdownDocument } from "../../lib/markdownDocument";
3 import { pullRequestDescriptionContent } from "./pullRequestDescriptionContent";
4
5 describe("pull request description content", () => {
6 + it("ignores malformed image URLs while keeping the description and valid attachments", () => {
7 + const result = pullRequestDescriptionContent(
8 + parseMarkdownDocument(
9 + [
10 + "The pull request remains readable.",
11 + "![Missing host](https://)",
12 + "![Invalid host](<https://a b>)",
13 + '<img src="https://:80" alt="Invalid port">',
14 + "![Unsupported](file:///screenshots/local.png)",
15 + "![Screenshot](http://example.com/screenshot.png)",
16 + ].join("\n\n"),
17 + ),
18 + );
19 +
20 + expect(result.attachments).toEqual([
21 + { uri: "http://example.com/screenshot.png", caption: "Screenshot", kind: "image" },
22 + ]);
23 + expect(result.preview).toContain("The pull request remains readable.");
24 + });
25 +
26 it("keeps screenshot attachments and does not turn code examples or local paths into media", () => {
27 const result = pullRequestDescriptionContent(
28 parseMarkdownDocument(
apps/mobile/src/features/pull-requests/pullRequestDescriptionContent.ts
+10 -1
@@ -1,6 +1,15 @@
1 import type { PullRequestBodySegment } from "@t3tools/client-runtime/pull-request-markdown";
2 import type { MarkdownNode } from "../../lib/markdownDocument";
3
4 +function isWebUrl(url: string): boolean {
5 + try {
6 + const parsed = new URL(url);
7 + return parsed.protocol === "https:" || parsed.protocol === "http:";
8 + } catch {
9 + return false;
10 + }
11 +}
12 +
13 export function pullRequestDescriptionContent(
14 document: MarkdownNode,
15 media: readonly PullRequestBodySegment[] = [],
@@ -12,7 +21,7 @@ export function pullRequestDescriptionContent(
21 const text: string[] = [];
22 const visit = (node: MarkdownNode) => {
23 if (node.type === "image") {
15 - if (node.url && /^https?:\/\//i.test(node.url) && !attachments.has(node.url)) {
24 + if (node.url && isWebUrl(node.url) && !attachments.has(node.url)) {
25 attachments.set(node.url, {
26 uri: node.url,
27 caption: node.alt || node.title || "Image",