Skip to content

Commit 0dfef84

Browse files
author
Adam Warner
authored
Merge pull request #18 from rgomez90/development
Check for invalid StringSplitter maxChunk
2 parents 0841f8c + c59f4fd commit 0dfef84

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Matterhook.NET.MatterhookClient/StringSplitter.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ public class StringSplitter
1818
/// <returns></returns>
1919
public static IEnumerable<string> SplitTextIntoChunks(string str, int maxChunkSize, bool preserveWords = true)
2020
{
21-
if (string.IsNullOrEmpty(str)) throw new ArgumentException("Text can't be null or empty",nameof(str));
21+
if (string.IsNullOrEmpty(str)) throw new ArgumentException("Text can't be null or empty.", nameof(str));
22+
if (maxChunkSize < 1) throw new ArgumentException("Max. chunk size must be at least 1 char.", nameof(maxChunkSize));
2223
if (str.Length < maxChunkSize) yield return str;
2324
else if (preserveWords)
2425
{

0 commit comments

Comments
 (0)