performance

This commit is contained in:
BaronGreenback 2021-02-27 21:17:58 +00:00
parent 053063fd47
commit 5074d67379

View File

@ -178,8 +178,9 @@ namespace MediaBrowser.Common.Net
// Use regular expression as CheckHostName isn't RFC5892 compliant.
// Modified from gSkinner's expression at https://stackoverflow.com/questions/11809631/fully-qualified-domain-name-validation
Regex re = new Regex(@"^(?!:\/\/)(?=.{1,255}$)((.{1,63}\.){0,127}(?![0-9]*$)[a-z0-9-]+\.?)$", RegexOptions.IgnoreCase | RegexOptions.Multiline);
if (re.Match(host).Success)
string pattern = @"(?im)^(?!:\/\/)(?=.{1,255}$)((.{1,63}\.){0,127}(?![0-9]*$)[a-z0-9-]+\.?)$";
if (Regex.IsMatch(host, pattern))
{
hostObj = new IPHost(host);
return true;