Skip to content

Commit

Permalink
Integrate Changes
Browse files Browse the repository at this point in the history
Integrate Changes
  • Loading branch information
gabrielforster authored Dec 8, 2023
2 parents 08ba96b + 022c2f9 commit 6bc68df
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 2 deletions.
11 changes: 11 additions & 0 deletions __tests__/files/index.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { getExtensionFromMimeType } from '../../src/files'

describe('Files', () => {
it('Should correct file extension from mimeType', () => {
expect(getExtensionFromMimeType('video/mp4')).toEqual('mp4')
})

it('Should return null as mimeType is unkown', () => {
expect(getExtensionFromMimeType('log/banana')).toBeNull()
})
})
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "adapcon-utils-js",
"version": "0.16.6",
"version": "0.16.7",
"description": "Utils library for Javascript",
"keywords": [],
"author": {
Expand Down
28 changes: 28 additions & 0 deletions src/files/extensions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
export enum FILE_EXTENSIONS {
'video/mp4' = 'mp4',
'audio/ogg; codecs=opus' = 'ogg',
'image/gif' = 'gif',
'image/jpeg' = 'jpg',
'image/svg+xml' = 'svg',
'image/tiff' = 'tiff',
'image/png' = 'png',
'image/bmp' = 'bmp',
'text/html' = 'html',
'text/csv' = 'csv',
'text/css' = 'css',
'text/plain' = 'txt',
'text/xml' = 'xml',
'text/tab-separated-values' = 'tsv',
'application/pdf' = 'pdf',
'application/xml' = 'xml',
'application/zip' = 'zip',
'application/x-compressed-zip' = 'zip',
'application/vnd.ms-excel' = 'xls',
'application/x-bzip2' = 'bz2',
'application/msword' = 'doc',
'application/x-gzip' = 'gz',
'application/java-archive' = 'jar',
'application/x-javascript' = 'js',
'application/vnd.ms-powerpoint' = 'ppt',
'application/x-tar' = 'tar.gz'
}
2 changes: 2 additions & 0 deletions src/files/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './extensions'
export * from './utils'
5 changes: 5 additions & 0 deletions src/files/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { FILE_EXTENSIONS } from '.'

export function getExtensionFromMimeType (mimeType: string): string | null {
return FILE_EXTENSIONS[mimeType] || null
}
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export * from './date'
export * from './dynamoose'
export * from './email'
export * from './error'
export * from './files'
export * from './http'
export * from './image'
export * from './invoice'
Expand Down

0 comments on commit 6bc68df

Please sign in to comment.