:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
import { describe, expect, it } from "vitest";
import { isValidAgentSlug } from "./agent-slug";
describe("isValidAgentSlug", () => {
it.each(["a", "my-agent", "agent123", "A1-b2", "x".repeat(63)])(
"accepts the DNS label %s",
(slug) => {
expect(isValidAgentSlug(slug)).toBe(true);
},
);
it.each([
"evil.com",
"evil.com/",
"evil.com#x",
"evil.com?x",
"evil.com:9999/",
"evil.com\\x",
"[email protected]",
"foo/../bar",
"foo bar",
"-lead",
"trail-",
"under_score",
"x".repeat(64),
"",
null,
undefined,
])("rejects %s", (slug) => {
expect(isValidAgentSlug(slug)).toBe(false);
});
});