Move another text helper method

This commit is contained in:
Matt Nadareski
2023-08-12 01:17:12 -04:00
parent ce6a64d4cd
commit 1752b1a0ac
7 changed files with 28 additions and 26 deletions

View File

@@ -1,3 +1,6 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
namespace SabreTools.Core.Tools
@@ -22,6 +25,18 @@ namespace SabreTools.Core.Tools
return input;
}
// <summary>
/// Remove all chars that are considered path unsafe
/// </summary>
public static string? RemovePathUnsafeCharacters(string? input)
{
if (string.IsNullOrWhiteSpace(input))
return input;
List<char> invalidPath = Path.GetInvalidPathChars().ToList();
return new string(input.Where(c => !invalidPath.Contains(c)).ToArray());
}
#region Helpers
/// <summary>

View File

@@ -1,7 +1,5 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace SabreTools.Core.Tools
{
@@ -175,18 +173,7 @@ namespace SabreTools.Core.Tools
return array == null || array.Length == 0;
}
/// <summary>
/// Remove all chars that are considered path unsafe
/// </summary>
/// <param name="s">Input string to clean</param>
/// <returns>Cleaned string</returns>
public static string RemovePathUnsafeCharacters(string s)
{
List<char> invalidPath = Path.GetInvalidPathChars().ToList();
return new string(s.Where(c => !invalidPath.Contains(c)).ToArray());
}
/// <summary>
//// <summary>
/// Returns if the first byte array starts with the second array
/// </summary>
/// <param name="arr1">First byte array to compare</param>