Skip to content
This repository was archived by the owner on Jun 25, 2020. It is now read-only.

Commit 0e5338f

Browse files
YamlExtensions.ExcludeHeader refactoring
1 parent 1c01232 commit 0e5338f

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/Pretzel.Logic/Extensions/YamlExtensions.cs

+5-5
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,11 @@ public static string ExcludeHeader(this string text)
109109
if (m.Count == 0)
110110
return text;
111111

112-
text = text.Replace(m[0].Groups[0].Value, "");
113-
var lines = text.Split(new[] { "\r\n", "\n" }, StringSplitOptions.None).ToList();
114-
while (lines.Any() && string.IsNullOrWhiteSpace(lines.First()))
115-
lines.RemoveAt(0);
116-
return string.Join(Environment.NewLine, lines).TrimEnd();
112+
var textWithoutHeader = text.Replace(m[0].Groups[0].Value, "").TrimEnd();
113+
var lines = textWithoutHeader.Split(new[] { "\r\n", "\n" }, StringSplitOptions.None);
114+
var targetLines = lines.SkipWhile(string.IsNullOrEmpty);
115+
var targetText = string.Join(Environment.NewLine, targetLines);
116+
return targetText;
117117
}
118118
}
119119
}

0 commit comments

Comments
 (0)