1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
8 * Truncate the string and add ellipsis to the middle of the string.
10 function truncateString(str, maxLength) {
11 if (!str || str.length <= maxLength) {
16 str.substring(0, Math.ceil(maxLength / 2)) +
18 str.substring(str.length - Math.floor(maxLength / 2))
22 exports.truncateString = truncateString;