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
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:
@@ -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);
|
||||
});
|
||||
});
|
||||
@@ -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);
|
||||
}
|
||||
Reference in New Issue
Block a user