fix: attachments broken
Some checks failed
Build Android APK / build-android-apk (push) Failing after 3m5s
Queue Release Build / prepare (push) Successful in 32s
Deploy Web Apps / deploy (push) Successful in 9m30s
Queue Release Build / build-windows (push) Successful in 28m7s
Queue Release Build / build-linux (push) Successful in 47m6s
Queue Release Build / finalize (push) Successful in 58s

This commit is contained in:
2026-06-05 08:02:29 +02:00
parent 9a1305f976
commit 35f52b0356
5 changed files with 67 additions and 42 deletions

View File

@@ -0,0 +1,20 @@
import {
isBlobObjectUrl,
isFileProtocolObjectUrl,
needsBlobObjectUrlForInlineDisplay
} from './attachment-display-url.rules';
describe('attachment display url rules', () => {
it('detects blob and file protocol urls', () => {
expect(isBlobObjectUrl('blob:http://localhost/abc')).toBe(true);
expect(isBlobObjectUrl('file:///tmp/video.mp4')).toBe(false);
expect(isFileProtocolObjectUrl('file:///tmp/video.mp4')).toBe(true);
expect(isFileProtocolObjectUrl('blob:http://localhost/abc')).toBe(false);
});
it('requires blob urls for inline display when missing or file protocol', () => {
expect(needsBlobObjectUrlForInlineDisplay(undefined)).toBe(true);
expect(needsBlobObjectUrlForInlineDisplay('file:///appdata/image.png')).toBe(true);
expect(needsBlobObjectUrlForInlineDisplay('blob:http://localhost/abc')).toBe(false);
});
});

View File

@@ -0,0 +1,11 @@
export function isBlobObjectUrl(url: string): boolean {
return url.startsWith('blob:');
}
export function isFileProtocolObjectUrl(url: string): boolean {
return url.startsWith('file:');
}
export function needsBlobObjectUrlForInlineDisplay(objectUrl?: string): boolean {
return !objectUrl || isFileProtocolObjectUrl(objectUrl);
}