pleroma/app/soapbox/utils/media.ts
2022-03-30 10:40:09 -04:00

10 lines
270 B
TypeScript

export const truncateFilename = (url, maxLength) => {
const filename = url.split('/').pop();
if (filename.length <= maxLength) return filename;
return [
filename.substr(0, maxLength/2),
filename.substr(filename.length - maxLength/2),
].join('…');
};