the universal sandbox runtime for agents and humans. pocketenv.io
sandbox openclaw agent claude-code vercel-sandbox deno-sandbox cloudflare-sandbox atproto sprites daytona
7
fork

Configure Feed

Select the types of activity you want to include in your feed.

at main 53 lines 1.6 kB view raw
1import { describe, it, expect } from "vitest"; 2import redact from "./redact.ts"; 3 4describe("redact", () => { 5 it("returns the value unchanged when 14 chars or fewer", () => { 6 expect(redact("short")).toBe("short"); 7 expect(redact("exactly14chars")).toBe("exactly14chars"); 8 }); 9 10 it("redacts strings longer than 14 chars", () => { 11 const result = redact("ghp_abcdefghijklmnopqrstuvwxyz"); 12 expect(result).toMatch(/^ghp_abcdefg\*{24}xyz$/); 13 }); 14 15 it("keeps the first 11 characters visible", () => { 16 const value = "123456789012345"; 17 const result = redact(value); 18 expect(result.startsWith("12345678901")).toBe(true); 19 }); 20 21 it("keeps the last 3 characters visible", () => { 22 const value = "123456789012345"; 23 const result = redact(value); 24 expect(result.endsWith("345")).toBe(true); 25 }); 26 27 it("uses exactly 24 asterisks in the middle", () => { 28 const value = "123456789012345"; 29 const result = redact(value); 30 const middle = result.slice(11, result.length - 3); 31 expect(middle).toBe("*".repeat(24)); 32 }); 33 34 it("total length is always 11 + 24 + 3 = 38 for any long string", () => { 35 for (const value of [ 36 "123456789012345", 37 "a".repeat(50), 38 "ghp_" + "x".repeat(40), 39 ]) { 40 expect(redact(value).length).toBe(38); 41 } 42 }); 43 44 it("handles a string of exactly 15 chars (boundary)", () => { 45 const value = "abcdefghijklmno"; 46 const result = redact(value); 47 expect(result).toBe("abcdefghijk" + "*".repeat(24) + "mno"); 48 }); 49 50 it("handles an empty string", () => { 51 expect(redact("")).toBe(""); 52 }); 53});