mirror of
https://github.com/openclaw/clawhub.git
synced 2026-08-14 08:52:21 +00:00
* fix: preserve complete skill artifacts * test: align artifact metadata expectations * fix: harden complete skill artifact handling * fix: close complete artifact review gaps * fix: preserve legacy skill file metadata hints * fix: close artifact presentation review gaps * fix(cli): preserve legacy skill file collector export * refactor: centralize artifact upload helpers * fix: preserve artifact scan and publish bounds * fix: scan complete published text artifacts * fix: harden artifact download presentation * test: avoid secret-like fixture text * refactor: preview artifacts by content * chore(deps): patch transitive audit advisories
19 lines
754 B
TypeScript
19 lines
754 B
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { decodeBoundedUtf8Text } from "./artifactText";
|
|
|
|
describe("decodeBoundedUtf8Text", () => {
|
|
it("decodes a bounded prefix of a larger UTF-8 artifact", () => {
|
|
const bytes = new TextEncoder().encode(`dangerous-prefix\n${"a".repeat(1024)}`);
|
|
expect(decodeBoundedUtf8Text(bytes, 64)).toContain("dangerous-prefix");
|
|
});
|
|
|
|
it("accepts a prefix ending in a partial multi-byte character", () => {
|
|
const bytes = new TextEncoder().encode(`abc😀${"z".repeat(32)}`);
|
|
expect(decodeBoundedUtf8Text(bytes, 5)).toBe("abc");
|
|
});
|
|
|
|
it("rejects invalid UTF-8 within the inspected prefix", () => {
|
|
expect(decodeBoundedUtf8Text(Uint8Array.from([0, 1, 2, 255, 97]), 4)).toBeNull();
|
|
});
|
|
});
|