Add link understanding tool support (#1637)

* Add

* Fix

---------

Co-authored-by: Richard <dasilva333@DESKTOP-74E3GJO.localdomain>
This commit is contained in:
Richard Pinedo
2026-01-24 19:15:54 -05:00
committed by GitHub
parent 2f58d59f22
commit 426168a338
13 changed files with 323 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
import { describe, expect, it } from "vitest";
import { extractLinksFromMessage } from "./detect.js";
describe("extractLinksFromMessage", () => {
it("extracts bare http/https URLs in order", () => {
const links = extractLinksFromMessage("see https://a.example and http://b.test");
expect(links).toEqual(["https://a.example", "http://b.test"]);
});
it("dedupes links and enforces maxLinks", () => {
const links = extractLinksFromMessage("https://a.example https://a.example https://b.test", {
maxLinks: 1,
});
expect(links).toEqual(["https://a.example"]);
});
it("ignores markdown links", () => {
const links = extractLinksFromMessage("[doc](https://docs.example) https://bare.example");
expect(links).toEqual(["https://bare.example"]);
});
it("blocks 127.0.0.1", () => {
const links = extractLinksFromMessage("http://127.0.0.1/test https://ok.test");
expect(links).toEqual(["https://ok.test"]);
});
});