mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 11:34:59 +00:00
Add link understanding tool support (#1637)
* Add * Fix --------- Co-authored-by: Richard <dasilva333@DESKTOP-74E3GJO.localdomain>
This commit is contained in:
27
src/link-understanding/detect.test.ts
Normal file
27
src/link-understanding/detect.test.ts
Normal 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"]);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user