private static bool IsDomainStart(char c, bool allowInternational, out SubDomainType type) { if (c < 128) { if (IsLetter(c)) { type = SubDomainType.Alphabetic; return(true); } if (IsDigit(c)) { type = SubDomainType.Numeric; return(true); } type = SubDomainType.None; return(false); } if (allowInternational) { type = SubDomainType.Alphabetic; return(true); } type = SubDomainType.None; return(false); }
private static bool IsDomain(char c, bool allowInternational, ref SubDomainType type) { if (c < 128) { if (IsLetter(c) || c == '-') { type |= SubDomainType.Alphabetic; return(true); } if (IsDigit(c)) { type |= SubDomainType.Numeric; return(true); } return(false); } if (allowInternational) { type |= SubDomainType.Alphabetic; return(true); } return(false); }
private static bool SkipSubDomain(string text, ref int index, bool allowInternational, out SubDomainType type) { var startIndex = index; if (!IsDomainStart(text[index], allowInternational, out type)) { return(false); } index++; while (index < text.Length && IsDomain(text[index], allowInternational, ref type)) { index++; } return(index - startIndex < 64 && text[index - 1] != '-'); }
static bool SkipSubDomain(string text, ref int index, bool allowInternational, out SubDomainType type) { int startIndex = index; if (!IsDomainStart(text[index], allowInternational, out type)) { return(false); } index++; while (index < text.Length && IsDomain(text[index], allowInternational, ref type)) { index++; } // Don't allow single-character top-level domains. if (index == text.Length && (index - startIndex) == 1) { return(false); } return((index - startIndex) <= 64 && text[index - 1] != '-'); }