mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-30 19:59:35 +00:00
fix(imessage): accept scheme-less URL previews
This commit is contained in:
@@ -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(
|
||||
|
||||
@@ -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:";
|
||||
|
||||
Reference in New Issue
Block a user