• Mark Florian's avatar
    Fix infinite loop in truncation algorithm · 85186eb8
    Mark Florian authored
    This algorithm doesn't handle the case when a path, fully-ellipsised, is
    still longer than the specified maxWidth.
    
    For example, for a path with 21 segments, the string the util would
    build is …/…/…/…/…/…/…/…/…/…/…/…/…/…/…/…/…/…/…/…/…, which is 41
    characters long, so the `while` condition is never false, leading to the
    infinite loop.
    
    This adds a condition to handle that case, returning a truncated string
    that never exceeds the maxWidth, no matter how deep the path is.
    85186eb8
text_utility_spec.js 9.3 KB