export default class Attachment { constructor({ publicUrl, fileName }) { this.publicUrl = publicUrl; this.kind = getKindByFileName(fileName); this.fileName = fileName; } } function getKindByFileName(fileName) { if (createExtensionRegExp(['jpg', 'jpeg', 'png']).test(fileName.toLowerCase())) return 'image'; else if (createExtensionRegExp(['mp4']).test(fileName.toLowerCase())) return 'video'; return 'document'; }; function createExtensionRegExp(extensions) { return new RegExp(`^.*\\.(${extensions.join('|')})$`); }