data-url.test.ts 482 B

1234567891011121314
  1. import { describe, expect, test } from "bun:test"
  2. import { decodeDataUrl } from "../../src/util/data-url"
  3. describe("decodeDataUrl", () => {
  4. test("decodes base64 data URLs", () => {
  5. const body = '{\n "ok": true\n}\n'
  6. const url = `data:text/plain;base64,${Buffer.from(body).toString("base64")}`
  7. expect(decodeDataUrl(url)).toBe(body)
  8. })
  9. test("decodes plain data URLs", () => {
  10. expect(decodeDataUrl("data:text/plain,hello%20world")).toBe("hello world")
  11. })
  12. })