123123
This commit is contained in:
@@ -3,6 +3,9 @@ using System.Text.RegularExpressions;
|
||||
|
||||
namespace ZelWiki.Library
|
||||
{
|
||||
/// <summary>
|
||||
/// 导航
|
||||
/// </summary>
|
||||
public class Navigation
|
||||
{
|
||||
public static string Clean(string? str)
|
||||
@@ -11,30 +14,26 @@ namespace ZelWiki.Library
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
//Fix names like "::Page" or "Namespace::".
|
||||
|
||||
str = str.Trim().Trim([':']).Trim();
|
||||
|
||||
if (str.Contains("::"))
|
||||
{
|
||||
throw new Exception("Navigation can not contain a namespace.");
|
||||
throw new Exception("导航不能包含命名空间");
|
||||
}
|
||||
|
||||
// Decode common HTML entities
|
||||
|
||||
str = str.Replace(""", "\"")
|
||||
.Replace("&", "&")
|
||||
.Replace("<", "<")
|
||||
.Replace(">", ">")
|
||||
.Replace(" ", " ");
|
||||
|
||||
// Normalize backslashes to forward slashes
|
||||
|
||||
str = str.Replace('\\', '/');
|
||||
|
||||
// Replace special sequences
|
||||
|
||||
str = str.Replace("::", "_").Trim();
|
||||
|
||||
var sb = new StringBuilder();
|
||||
foreach (char c in str)
|
||||
foreach (var c in str)
|
||||
{
|
||||
if (char.IsWhiteSpace(c) || c == '.')
|
||||
{
|
||||
@@ -46,9 +45,8 @@ namespace ZelWiki.Library
|
||||
}
|
||||
}
|
||||
|
||||
string result = sb.ToString();
|
||||
var result = sb.ToString();
|
||||
|
||||
// Remove multiple consecutive underscores or slashes
|
||||
result = Regex.Replace(result, @"[_]{2,}", "_");
|
||||
result = Regex.Replace(result, @"[/]{2,}", "/");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user