BitServer.Bitmessage.ParseAddress C# (CSharp) Method

ParseAddress() public static method

Returns the bitmessage address, BROADCAST or null if invalid address.
public static ParseAddress ( string p, bool allowBroadcast ) : string
p string E-Mail Address to check
allowBroadcast bool true, if broadcast address is valid
return string
        public static string ParseAddress(string p,bool allowBroadcast)
        {
            p = p.Replace("<", "").Replace(">", "").Trim();
            if (!p.ToLower().Contains("@" + DOMAIN))
            {
                return null;
            }
            if(p.Contains(" "))
            {
                p = p.Substring(p.LastIndexOf(' ') + 1);
            }
            if (p.ToUpper().StartsWith(BROADCAST + "@"))
            {
                return allowBroadcast ? BROADCAST : null;
            }
            if (p.ToUpper().StartsWith(ADDRESS + "@"))
            {
                return allowBroadcast ? ADDRESS : null;
            }
            if (p.StartsWith("BM-"))
            {
                return p.Split('@')[0];
            }
            else
            {
                return null;
            }
        }