// Copyright (c) Umbraco. // See LICENSE for more details. namespace Umbraco.Cms.Tests.Common.TestHelpers; public static class StringNewLineExtensions { /// /// Ensures Lf only everywhere. /// /// The text to filter. /// The filtered text. public static string Lf(this string text) { if (string.IsNullOrEmpty(text)) { return text; } text = text.Replace("\r", string.Empty); // remove CR return text; } /// /// Ensures CrLf everywhere. /// /// The text to filter. /// The filtered text. public static string CrLf(this string text) { if (string.IsNullOrEmpty(text)) { return text; } text = text.Replace("\r", string.Empty); // remove CR text = text.Replace("\n", "\r\n"); // add CRLF everywhere return text; } /// /// Replaces Cr/Lf by a single space. /// /// The text to filter. /// The filtered text. public static string NoCrLf(this string text) { if (string.IsNullOrEmpty(text)) { return text; } text = text.Replace("\r\n", " "); // remove CRLF text = text.Replace("\r", " "); // remove CR text = text.Replace("\n", " "); // remove LF return text; } }