Update docs

This commit is contained in:
Alan Grainger
2026-10-07 18:04:57 +13:00
parent 7a9ff2e6ee
commit 172f247418
14 changed files with 243 additions and 37 deletions
+15 -1
View File
@@ -1,5 +1,5 @@
import { describe, it, expect } from 'vitest'
import { fileType, formatSize, isUploadableType } from '../src/shared/upload'
import { fileType, formatSize, isUploadableName, isUploadableType } from '../src/shared/upload'
import { declaredLength, uploadTimestamp } from '../src/receive'
describe('isUploadableType', () => {
@@ -22,6 +22,20 @@ describe('isUploadableType', () => {
})
})
describe('isUploadableName', () => {
it('refuses an SVG extension whatever type the request declares', () => {
expect(isUploadableName('evil.svg')).toBe(false)
expect(isUploadableName('ipp_upload_evil.SVG')).toBe(false)
expect(isUploadableName('evil.svgz')).toBe(false)
})
it('accepts photo and video extensions, and leaves the finer check to Immich', () => {
expect(isUploadableName('IMG_0042.jpg')).toBe(true)
expect(isUploadableName('clip.mp4')).toBe(true)
expect(isUploadableName('my.svg.jpg')).toBe(true)
})
})
describe('fileType', () => {
it('keeps the type the browser gave', () => {
expect(fileType('IMG_0042.HEIC', 'image/heic')).toBe('image/heic')