diff --git a/Shared/Extensions/StringExtensions.cs b/Shared/Extensions/StringExtensions.cs index 1e295a9..58d2a99 100644 --- a/Shared/Extensions/StringExtensions.cs +++ b/Shared/Extensions/StringExtensions.cs @@ -89,7 +89,7 @@ public static class StringExtensions { if (splitStr.IsSingle()) { return fullStr.Split(splitStr[0], removeEmptyEntries); } else { - return fullStr.Split([splitStr], removeEmptyEntries ? StringSplitOptions.RemoveEmptyEntries : StringSplitOptions.None); + return fullStr.Split([splitStr], removeEmptyEntries); } } /// @@ -97,7 +97,19 @@ public static class StringExtensions { /// 若原始字符串为空,则返回 {""}。 /// public static string[] Split(this string fullStr, char splitChar, bool removeEmptyEntries = false) - => fullStr.Split([splitChar], removeEmptyEntries ? StringSplitOptions.RemoveEmptyEntries : StringSplitOptions.None); + => fullStr.Split([splitChar], removeEmptyEntries); + /// + /// 分割字符串。 + /// 若原始字符串为空,则返回 {""}。 + /// + public static string[] Split(this string fullStr, string[] splitStrings, bool removeEmptyEntries = false) + => fullStr.Split(splitStrings, removeEmptyEntries ? StringSplitOptions.RemoveEmptyEntries : StringSplitOptions.None); + /// + /// 分割字符串。 + /// 若原始字符串为空,则返回 {""}。 + /// + public static string[] Split(this string fullStr, char[] splitChars, bool removeEmptyEntries = false) + => fullStr.Split(splitChars, removeEmptyEntries ? StringSplitOptions.RemoveEmptyEntries : StringSplitOptions.None); /// /// 获取在子字符串第一次出现之前的部分,如果未找到子字符串则不裁切。 diff --git a/Tests/Utils/PathUtilsTest.cs b/Tests/Utils/PathUtilsTest.cs index 386ab6b..45cc08e 100644 --- a/Tests/Utils/PathUtilsTest.cs +++ b/Tests/Utils/PathUtilsTest.cs @@ -32,6 +32,7 @@ public class PathUtilsTests : TestBase { [Arguments("https://foo.bar/file/", "file")] [Arguments("https://foo.bar/file/?arg=1", "file")] [Arguments("https://foo.bar/File?arg=1", "File")] + [Arguments("https://cdn.modrinth.com/data/RvfAlf4Z/versions/XauQUBeR/Redstone Tweaks 2.5.3.zip?mr_download_reason=modpack", "Redstone Tweaks 2.5.3.zip")] public async Task 路径处理_GetLastPart(string input, string expected) => await Assert.That(PathUtils.GetLastPart(input)).IsEqualTo(expected);