feat: quote #42

Merged
Anri merged 16 commits from feat/citation into main 2022-07-27 13:00:24 +02:00
Showing only changes of commit b5016bb39b - Show all commits

View file

@ -36,3 +36,25 @@ export const removeExtension = (filename: string) => {
return array.join('.'); return array.join('.');
}; };
/**
* Get extension from a filename.
* @param filename string of the filename
* @returns string of the extension if it exists
*/
export const getExtension = (filename: string) => {
const array = filename.split('.');
return array.pop();
};
/**
* Define if a media is a media based on file extension.
* @param filename string of the filename
* @returns true is file is a media
*/
export const isImage = (filename: string) => {
return Boolean(getExtension(filename)?.match(
/jpg|jpeg|png|webp|gif/
));
};