System.Net.CookieContainer.CookieContainer.CheckDomain C# (CSharp) Method

CheckDomain() static private method

static private CheckDomain ( string domain, string host, bool exact ) : bool
domain string
host string
exact bool
return bool
		static bool CheckDomain (string domain, string host, bool exact)
		{
			if (domain.Length == 0)
				return false;

			if (exact)
				return (String.Compare (host, domain, true, CultureInfo.InvariantCulture) == 0);

			// check for allowed sub-domains - without string allocations
			if (!CultureInfo.InvariantCulture.CompareInfo.IsSuffix (host, domain, CompareOptions.IgnoreCase))
				return false;

			// mono.com -> www.mono.com is OK but supermono.com NOT OK
			if (domain [0] == '.')
				return true;
			int p = host.Length - domain.Length - 1;
			if (p < 0)
				return false;
			return (host [p] == '.');
		}