3 module
.exports
= function trim(name
, maxLength
) {
4 maxLength
= maxLength
|| 25; // defaults to 25
6 if (!name
|| name
.length
< maxLength
) return name
; // avoid computing
8 var parts
= name
.split('/'); // break it down
10 for (var i
= 1; i
< parts
.length
; i
++) {
11 var sub
= parts
.slice(i
).join('/');
12 if (sub
.length
<= maxLength
) return sub
; // trying to compose a smaller part that makes sense
15 // if all else fails, return the first part only