mirror of
https://github.com/farcasclaudiu/openclaw.git
synced 2026-06-28 21:01:43 +03:00
fix: avoid directive hits inside URLs and add tests
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { extractVerboseDirective, extractThinkDirective } from "./reply.js";
|
||||
|
||||
describe("directive parsing", () => {
|
||||
it("ignores verbose directive inside URL", () => {
|
||||
const body = "https://x.com/verioussmith/status/1997066835133669687";
|
||||
const res = extractVerboseDirective(body);
|
||||
expect(res.hasDirective).toBe(false);
|
||||
expect(res.cleaned).toBe(body);
|
||||
});
|
||||
|
||||
it("ignores think directive inside URL", () => {
|
||||
const body = "see https://example.com/path/thinkstuff";
|
||||
const res = extractThinkDirective(body);
|
||||
expect(res.hasDirective).toBe(false);
|
||||
});
|
||||
|
||||
it("matches verbose with leading space", () => {
|
||||
const res = extractVerboseDirective(" please /verbose on now");
|
||||
expect(res.hasDirective).toBe(true);
|
||||
expect(res.verboseLevel).toBe("on");
|
||||
});
|
||||
|
||||
it("matches think at start of line", () => {
|
||||
const res = extractThinkDirective("/think:high run slow");
|
||||
expect(res.hasDirective).toBe(true);
|
||||
expect(res.thinkLevel).toBe("high");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user