/// <summary> /// This method returns True if the specified domain matches the Origin Domain. /// </summary> /// <remarks>TODO: This is hideously ugly, but we wanted to support regex for some reason rather than wild carded item names.</remarks> /// <param name="domain">The host name to compare to the Origin Domain.</param> /// <returns>True if the given name matches the Origin Domain or the Origin Domain is empty; False if otherwise.</returns> public Boolean IsOriginDomain(String domain) { if (String.IsNullOrEmpty(OriginDomain)) { return(true); } String regex = OriginDomain.Trim().ToLower().Replace(".", "\\.").Replace("*", ".*"); return(Regex.IsMatch(domain, regex)); }
/// <summary> /// This overload checks if the domain name passed in matches the origin domain configured by /// the user. If an origin domain was not configured, then this check's allows an origin domain /// to be assumed by Watcher, specified through the two parameters. Expected use: /// IsOriginDomain(session.hostname, session.hostname) /// </summary> /// <param name="domain">The session hostname of the response.</param> /// <param name="responsedomain">Also the session hostname of the response.</param> /// <returns>True if the two parameters match, false otherwise.</returns> public Boolean IsOriginDomain(String domain, String responsedomain) { if (String.IsNullOrEmpty(OriginDomain)) { String _responsedomain = responsedomain.Trim().ToLower(); String _domain = domain.Trim().ToLower(); return(Regex.IsMatch(_domain, _responsedomain)); } String regex = OriginDomain.Trim().ToLower().Replace(".", "\\.").Replace("*", ".*"); return(Regex.IsMatch(domain, regex)); }