mirror of
https://github.com/Viren070/AIOStreams.git
synced 2025-12-01 23:14:04 +01:00
fix(core/formatter): remove trailing whitespace before truncating (#476)
This commit is contained in:
@@ -700,7 +700,9 @@ export abstract class BaseFormatter {
|
||||
const n = parseInt(inside, 10);
|
||||
if (!isNaN(n) && n >= 0) {
|
||||
if (variable.length > n) {
|
||||
return variable.slice(0, n) + '…';
|
||||
// Truncate to N characters and remove trailing whitespace
|
||||
const truncated = variable.slice(0, n).replace(/\s+$/, '');
|
||||
return truncated + '…';
|
||||
}
|
||||
return variable;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user