The best way to control Claude Code, Codex and more from any computer or phone
fix(shared): preview_open reports about: and mailto: as unsupported instead of misreading them (#29614)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: maria-rcks <maria@kuuro.net>
Alex Southwell committed
Nov 3, 2026 at 23:36 UTC
87049668615717241c1bd4449e872ae82ab1702e
2 files changed
+22
packages/shared/src/preview.test.ts
+14
@@ -179,4 +179,18 @@ describe("normalizePreviewUrl", () => {
179
);
180
}
181
});
182
+
183
+ it("reports explicit non-web schemes instead of reading them as a host", () => {
184
+ for (const [rawUrl, protocol] of [
185
+ ["about:blank", "about:"],
186
+ ["mailto:alice@example.com", "mailto:"],
187
+ ["javascript:alert(1)", "javascript:"],
188
+ ] as const) {
189
+ expect(() => normalizePreviewUrl(rawUrl)).toThrow(
190
+ expect.objectContaining({ reason: "unsupported-protocol", protocol }),
191
+ );
192
+ }
193
+ expect(normalizePreviewUrl("localhost:3000")).toBe("http://localhost:3000/");
194
+ expect(normalizePreviewUrl("devbox:8080")).toBe("https://devbox:8080/");
195
+ });
196
});
packages/shared/src/preview.ts
+8
@@ -185,6 +185,14 @@ export function normalizePreviewUrl(rawUrl: string): string {
185
if (trimmed.length === 0) {
186
throw new PreviewUrlNormalizationError({ inputLength: rawUrl.length, reason: "empty" });
187
}
188
+ const explicitProtocol = previewUrlProtocol(trimmed);
189
+ if (explicitProtocol !== undefined && KNOWN_NON_WEB_SCHEMES.has(explicitProtocol)) {
190
+ throw new PreviewUrlNormalizationError({
191
+ inputLength: rawUrl.length,
192
+ reason: "unsupported-protocol",
193
+ protocol: explicitProtocol,
194
+ });
195
+ }
196
const useHttp = LOOPBACK_PREFIX_PATTERN.test(trimmed);
197
const candidate = URL_SCHEME_WITH_AUTHORITY_PATTERN.test(trimmed)
198
? trimmed