OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 <include src="assert.js"> | 5 <include src="assert.js"> |
6 | 6 |
7 /** | 7 /** |
8 * The global object. | 8 * The global object. |
9 * @type {!Object} | 9 * @type {!Object} |
10 * @const | 10 * @const |
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 .replace(/"/g, '"') | 394 .replace(/"/g, '"') |
395 .replace(/'/g, '''); | 395 .replace(/'/g, '''); |
396 } | 396 } |
397 | 397 |
398 /** | 398 /** |
399 * Shortens the provided string (if necessary) to a string of length at most | 399 * Shortens the provided string (if necessary) to a string of length at most |
400 * |maxLength|. | 400 * |maxLength|. |
401 * @param {string} original The original string. | 401 * @param {string} original The original string. |
402 * @param {number} maxLength The maximum length allowed for the string. | 402 * @param {number} maxLength The maximum length allowed for the string. |
403 * @return {string} The original string if its length does not exceed | 403 * @return {string} The original string if its length does not exceed |
404 * |maxLength|. Otherwise the first |maxLength| - 3 characters with '...' | 404 * |maxLength|. Otherwise the first |maxLength| - 1 characters with '...' |
405 * appended. | 405 * appended. |
406 */ | 406 */ |
407 function elide(original, maxLength) { | 407 function elide(original, maxLength) { |
408 if (original.length <= maxLength) | 408 if (original.length <= maxLength) |
409 return original; | 409 return original; |
410 return original.substring(0, maxLength - 3) + '...'; | 410 return original.substring(0, maxLength - 1) + '\u2026'; |
411 } | 411 } |
OLD | NEW |