mirror of
https://github.com/outline/outline.git
synced 2026-11-20 21:23:06 +03:00
* feat: Support HEIC avatar uploads with in-browser conversion HEIC and HEIF images picked for an avatar are now converted to JPEG in the browser before the cropper opens. The browser's own decoder is used when it supports the format, otherwise a WebAssembly decoder is loaded on demand. Also collects the image utilities into an ImageHelper class, fixes the crop dialog's submit button never disabling, and stops the upload from forwarding request headers the browser controls itself. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * refactor: Use only the browser's own HEIC decoder Drops the bundled WebAssembly decoder in favour of the browser's native support. This removes an LGPL dependency and a 3MB lazy chunk, and lets the Content Security Policy stay as it was. Browsers without HEIC support now get a message asking for a JPEG or PNG. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * docs: Add class-level JSDoc to ImageHelper Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
32 lines
1.1 KiB
TypeScript
32 lines
1.1 KiB
TypeScript
import { ImageHelper } from "./ImageHelper";
|
|
|
|
const fileWith = (name: string, type: string) => new File([], name, { type });
|
|
|
|
describe("ImageHelper", () => {
|
|
describe("isHeic", () => {
|
|
it("matches HEIC and HEIF mime-types", () => {
|
|
expect(ImageHelper.isHeic(fileWith("photo", "image/heic"))).toBe(true);
|
|
expect(ImageHelper.isHeic(fileWith("photo", "image/heif"))).toBe(true);
|
|
expect(ImageHelper.isHeic(fileWith("photo", "image/heic-sequence"))).toBe(
|
|
true
|
|
);
|
|
expect(ImageHelper.isHeic(fileWith("photo", "IMAGE/HEIC"))).toBe(true);
|
|
});
|
|
|
|
it("matches by extension when the mime-type is missing", () => {
|
|
expect(ImageHelper.isHeic(fileWith("photo.heic", ""))).toBe(true);
|
|
expect(ImageHelper.isHeic(fileWith("photo.HEIF", ""))).toBe(true);
|
|
});
|
|
|
|
it("does not match other images", () => {
|
|
expect(ImageHelper.isHeic(fileWith("photo.png", "image/png"))).toBe(
|
|
false
|
|
);
|
|
expect(ImageHelper.isHeic(fileWith("photo.jpg", "image/jpeg"))).toBe(
|
|
false
|
|
);
|
|
expect(ImageHelper.isHeic(fileWith("heic.png", "image/png"))).toBe(false);
|
|
});
|
|
});
|
|
});
|