bigbuffet-rw/app/soapbox/utils/media.js
2020-09-06 16:44:19 -05:00

10 lines
270 B
JavaScript

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('…');
};