bigbuffet-rw/app/soapbox/utils/media.js

11 lines
270 B
JavaScript
Raw Normal View History

2020-09-06 14:44:19 -07:00
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('…');
};