Do not prepend empty lines with a timestamp in AutomatedUpdatesBasePage

`value` can sometimes be fed as a multiline string, in which case timestamps were added to empty lines, causing confusion.

Signed-off-by: Danilo Del Busso <danilo.delbusso@cloud.com>
This commit is contained in:
Danilo Del Busso 2022-12-12 09:42:48 +00:00 committed by Danilo Del Busso
parent fa04fda84a
commit 6f99bf4753

View File

@ -164,7 +164,14 @@ namespace XenAdmin.Core
var timestampString = HelpersGUI.DateTimeToString(timestamp, Messages.DATEFORMAT_DM_HMS, localize);
// normalise all line endings before splitting
var lines = value.Replace(Environment.NewLine, "\n").Split('\n');
return string.Join(Environment.NewLine, lines.Select(line => $"{timestampString} | {line}"));
return string.Join(Environment.NewLine, lines.Select(line =>
{
if (string.IsNullOrWhiteSpace(line))
{
return line;
}
return $"{timestampString} | {line}";
}));
}
}
}