public Realm(string realmUrl) {
Requires.NotNull(realmUrl, "realmUrl"); // not non-zero check so we throw UriFormatException later
this.DomainWildcard = Regex.IsMatch(realmUrl, WildcardDetectionPattern);
this.uri = new Uri(Regex.Replace(realmUrl, WildcardDetectionPattern, m => m.Groups[1].Value));
if (!this.uri.Scheme.Equals("http", StringComparison.OrdinalIgnoreCase) &&
!this.uri.Scheme.Equals("https", StringComparison.OrdinalIgnoreCase)) {
throw new UriFormatException(
string.Format(CultureInfo.CurrentCulture, OpenIdStrings.InvalidScheme, this.uri.Scheme));
}
}