fix: reliable file manager saves with sudo prompt and no base64 guessing (#1335)

This commit is contained in:
LukeGus committed 2026-09-30 12:12:41 -05:00
1 parent f896e121e2
commit e3eada899c
3 files changed
+87 -38

No files matched your search

@@ -0,0 +1,21 @@
import { describe, expect, it } from "vitest";
import { decodeWriteContent } from "../../src/backend/content-routes.js";
describe("decodeWriteContent", () => {
it("keeps text that happens to be valid base64", () => {
expect(decodeWriteContent("test").toString("utf8")).toBe("test");
expect(decodeWriteContent("abcd1234").toString("utf8")).toBe("abcd1234");
});
it("decodes base64 only when asked", () => {
const encoded = Buffer.from("local x = 1\n").toString("base64");
expect(decodeWriteContent(encoded, "base64").toString("utf8")).toBe(
"local x = 1\n",
);
});
it("passes buffers through", () => {
const buffer = Buffer.from([0, 1, 2]);
expect(decodeWriteContent(buffer)).toBe(buffer);
});
});