懒得勤快 5 years ago
parent
commit
f0302a6254
1 changed files with 2 additions and 14 deletions
  1. 2 14
      src/Masuit.MyBlogs.Core/Common/CommonHelper.cs

+ 2 - 14
src/Masuit.MyBlogs.Core/Common/CommonHelper.cs

@@ -173,7 +173,7 @@ namespace Masuit.MyBlogs.Core.Common
 
         public static string GetIPLocation(this string ips)
         {
-            return ips.Split(',').Select(s => Searcher.MemorySearch(s)?.Region).Join(" , ");
+            return ips.Split(',', StringSplitOptions.RemoveEmptyEntries).Select(s => Searcher.MemorySearch(s.Trim())?.Region).Join(" , ");
         }
 
         /// <summary>
@@ -236,19 +236,7 @@ namespace Masuit.MyBlogs.Core.Common
             var nodes = doc.DocumentNode.Descendants("img");
             foreach (var node in nodes)
             {
-                string src = "";
-                if (node.Attributes.Contains("data-original"))
-                {
-                    src = node.Attributes["data-original"].Value;
-                }
-
-                if (node.Attributes.Contains("src"))
-                {
-                    src = node.Attributes["src"].Value;
-                }
-
-                node.Attributes.RemoveAll();
-                node.Attributes.Add("src", src);
+                node.Attributes.RemoveWhere(a => !new[] { "src", "data-original", "width", "style", "class" }.Contains(a.Name));
             }
 
             return doc.DocumentNode.OuterHtml;