using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace TemuKJD.BLL.VDian { public class MappingVDianApiBLL { public static string GetFormattedImgFileName(string oldName) { if (oldName == null) return ""; var imgStr = oldName; if (imgStr.EndsWith(".src")) imgStr = imgStr.Substring(0, imgStr.Length - 4); if (imgStr.Contains("@")) imgStr = imgStr.Substring(0, imgStr.LastIndexOf("@")); //omsproductionimg.yangkeduo.com/images/2017-12-06/c5286b86a0ef6a982dcabbdf517a7d55.jpeg@750w_1l_50Q.src if (imgStr.Contains("?") && !imgStr.ToLower().EndsWith(".jpg") && !imgStr.ToLower().EndsWith(".jpeg") && !imgStr.ToLower().EndsWith(".bmp") && !imgStr.ToLower().EndsWith(".png") && !imgStr.ToLower().EndsWith(".ss2") && !imgStr.ToLower().EndsWith(".gif")) imgStr = imgStr.Substring(0, imgStr.LastIndexOf("?")); if (!imgStr.StartsWith("http")) imgStr = "https://" + imgStr.TrimStart('/'); if (!imgStr.ToLower().EndsWith(".jpg") && !imgStr.ToLower().EndsWith(".jpeg") && !imgStr.ToLower().EndsWith(".png") && !imgStr.ToLower().EndsWith(".bmp") && !imgStr.ToLower().EndsWith(".ss2") && !imgStr.ToLower().EndsWith(".gif")) { if (imgStr.Contains("gw.alicdn.com")) return imgStr; return ""; } return imgStr; } } }