fix(imessage): accept scheme-less URL previews

This commit is contained in:
Omar Shahine
2026-06-21 16:02:53 -07:00
parent 91fbc4554a
commit 7fc3eca084
2 changed files with 14 additions and 0 deletions

View File

@@ -175,6 +175,17 @@ describe("isStandaloneIMessageUrlPreviewPayload", () => {
).toBe(true);
});
it("matches scheme-less www URL preview rows", () => {
expect(
isStandaloneIMessageUrlPreviewPayload(
makePayload({
text: "www.example.com/article",
balloon_bundle_id: IMESSAGE_URL_BALLOON_BUNDLE_ID,
}),
),
).toBe(true);
});
it("does not match already-complete URL balloon messages with text context", () => {
expect(
isStandaloneIMessageUrlPreviewPayload(

View File

@@ -26,6 +26,9 @@ function isSingleUrlToken(text: string): boolean {
if (/\s/.test(text)) {
return false;
}
if (/^www\.[^\s.]+\.[^\s]+$/i.test(text)) {
return true;
}
try {
const url = new URL(text);
return url.protocol === "http:" || url.protocol === "https:";