Selaa lähdekoodia

修复邮箱掩码方法的逻辑顺序问题

修复了在调用 `MatchEmail(s).isMatch` 之前对字符串 `s` 进行处理的顺序问题。原代码可能在输入无效邮箱时导致异常。调整后确保仅在邮箱格式正确时执行后续操作。
懒得勤快 3 viikkoa sitten
vanhempi
sitoutus
ef4d723d44

+ 2 - 2
Masuit.Tools.Abstractions/Extensions/BaseType/StringExtensions.cs

@@ -398,13 +398,13 @@ namespace Masuit.Tools
         /// <returns></returns>
         public static string MaskEmail(this string s, char mask = '*')
         {
-            var index = s.LastIndexOf("@");
-            var oldValue = s.Substring(0, index);
             if (!MatchEmail(s).isMatch)
             {
                 return s;
             }
 
+            var index = s.LastIndexOf("@");
+            var oldValue = s.Substring(0, index);
             var newValue = Mask(oldValue, mask);
             return newValue + s.Substring(index, s.Length - index);
         }