MCPcopy Create free account
hub / github.com/ZenNotes/zennotes / pastedImageExtension

Function pastedImageExtension

apps/desktop/src/main/vault.ts:2950–2958  ·  view source on GitHub ↗
(input: Pick<PastedImageInput, 'mimeType' | 'suggestedName'>)

Source from the content-addressed store, hash-verified

2948}
2949
2950function pastedImageExtension(input: Pick<PastedImageInput, 'mimeType' | 'suggestedName'>): string {
2951 const suggestedExt = path.extname(input.suggestedName ?? '').toLowerCase()
2952 if (IMAGE_EXTENSIONS.has(suggestedExt)) return suggestedExt
2953
2954 const mimeExt = PASTED_IMAGE_MIME_EXTENSIONS[input.mimeType.toLowerCase()]
2955 if (mimeExt) return mimeExt
2956 if (input.mimeType.toLowerCase().startsWith('image/')) return '.png'
2957 throw new Error('Clipboard item is not an image.')
2958}
2959
2960function pastedImageFilename(input: Pick<PastedImageInput, 'mimeType' | 'suggestedName'>, now: Date): string {
2961 const ext = pastedImageExtension(input)

Callers 1

pastedImageFilenameFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected