-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into deepsource-autofix-7fc1aff8
- Loading branch information
Showing
19 changed files
with
160 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[![DeepSource](https://app.deepsource.com/gh/Adapcon/adapcon-utils-js.svg/?label=active+issues&show_trend=true&token=z9o0q95BRMd2RWNUS_SdBYs0)](https://app.deepsource.com/gh/Adapcon/adapcon-utils-js/?ref=repository-badge) | ||
[![DeepSource](https://app.deepsource.com/gh/Adapcon/adapcon-utils-js.svg/?label=resolved+issues&show_trend=true&token=z9o0q95BRMd2RWNUS_SdBYs0)](https://app.deepsource.com/gh/Adapcon/adapcon-utils-js/?ref=repository-badge) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { stringToArray } from '../../src/string' | ||
|
||
describe('stringToArray', () => { | ||
const data = [ | ||
{ | ||
output: [] | ||
}, | ||
{ | ||
delimiter: ',', | ||
output: [] | ||
}, | ||
{ | ||
input: 'id,style,appId', | ||
output: ['id', 'style', 'appId'] | ||
}, | ||
{ | ||
input: 'id, style, appId', | ||
output: ['id', 'style', 'appId'] | ||
}, | ||
{ | ||
input: '', | ||
output: [] | ||
}, | ||
{ | ||
input: 'id', | ||
output: ['id'] | ||
}, | ||
{ | ||
input: 'id', | ||
delimiter: ',', | ||
output: ['id'] | ||
}, | ||
{ | ||
input: 'id;style;appId', | ||
delimiter: ';', | ||
output: ['id', 'style', 'appId'] | ||
} | ||
] | ||
|
||
test.each(data)('Should return array of string', (param) => { | ||
expect(stringToArray(param.input ? param.input : undefined, param.delimiter ? param.delimiter : undefined)).toStrictEqual(param.output) | ||
}) | ||
}) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './extensions' | ||
export * from './utils' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * from './validators' | ||
export * from './formatters' | ||
export * from './modifiers' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export const stringToArray = (str = '', delimiter = ','): string[] => { | ||
if (typeof str !== 'string' || str === '') return [] | ||
return str.split(delimiter).map((value) => value.trim()) | ||
} |