Fix shortening of filenames containing surrogate pairs.

This commit is contained in:
ccd0 2016-05-07 09:14:01 -07:00
parent 5844ad7943
commit dda29feda1

View File

@ -9,10 +9,9 @@ Build =
{'&amp;': '&', '&#039;': "'", '&quot;': '"', '&lt;': '<', '&gt;': '>', '&#44;': ','}[c]
shortFilename: (filename) ->
threshold = 30
ext = filename.match(/\.?[^\.]*$/)[0]
if filename.length - ext.length > threshold
"#{filename[...threshold - 5]}(...)#{ext}"
if filename.length - ext.length > 30
"#{filename.match(/(?:[\uD800-\uDBFF][\uDC00-\uDFFF]|[^]){0,25}/)[0]}(...)#{ext}"
else
filename