feat(channels): implement binary attachment upload for matrix/signal/mattermost
This commit is contained in:
@@ -388,3 +388,27 @@ function sanitizeFilename(filename?: string): string {
|
||||
function escapeRegex(value: string): string {
|
||||
return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
||||
}
|
||||
|
||||
function sanitizeFilename(name?: string): string {
|
||||
if (!name) {
|
||||
return '';
|
||||
}
|
||||
return name.replace(/[^a-zA-Z0-9._-]/g, '_').slice(0, 100);
|
||||
}
|
||||
|
||||
function extensionFromMimeType(mimeType?: string): string {
|
||||
if (!mimeType) {
|
||||
return '';
|
||||
}
|
||||
const simple = mimeType.split('/')[1]?.trim().toLowerCase();
|
||||
if (!simple) {
|
||||
return '';
|
||||
}
|
||||
if (simple.includes('jpeg')) {
|
||||
return '.jpg';
|
||||
}
|
||||
if (simple.includes('plain')) {
|
||||
return '.txt';
|
||||
}
|
||||
return `.${simple.replace(/[^a-z0-9]/g, '')}`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user