public static ToolStatistics GetToolStatisticsFromRequestUrl(string requestUrl, DateTime edgeServerTimeDelivered) { // Filter out non-valid request paths var lowerCaseRequestPath = requestUrl.ToLowerInvariant(); if (!lowerCaseRequestPath.EndsWith(".exe") && !lowerCaseRequestPath.EndsWith(".vsix")) { return(null); } var matches = Regex.Matches(requestUrl, @"(http[s]?[:]//dist.nuget.org/[\w]*\/nugetdist.blob.core.windows.net/artifacts/)(?<toolId>[\w-]+)/(?<toolVersion>[a-zA-Z0-9.-]+)/(?<fileName>[\w.]+)"); if (matches.Count == 1) { var match = matches[0]; var statistics = new ToolStatistics(); statistics.EdgeServerTimeDelivered = edgeServerTimeDelivered; statistics.ToolId = match.Groups["toolId"].Value.Trim(); statistics.ToolVersion = match.Groups["toolVersion"].Value.Trim(); statistics.FileName = match.Groups["fileName"].Value.Trim(); statistics.Path = string.Join("/", statistics.ToolId, statistics.ToolVersion, statistics.FileName); return(statistics); } return(null); }
public static ToolStatistics GetToolStatisticsFromRequestUrl(string requestUrl, DateTime edgeServerTimeDelivered) { var matches = Regex.Matches(requestUrl, @"(http[s]?[:]//dist.nuget.org/[\w]*\/nugetdist.blob.core.windows.net/artifacts/)(?<toolId>[\w-]+)/(?<toolVersion>[a-zA-Z0-9.-]+)/(?<fileName>[\w.]+)"); if (matches.Count == 1) { var match = matches[0]; var statistics = new ToolStatistics(); statistics.EdgeServerTimeDelivered = edgeServerTimeDelivered; statistics.ToolId = match.Groups["toolId"].Value.Trim(); statistics.ToolVersion = match.Groups["toolVersion"].Value.Trim(); statistics.FileName = match.Groups["fileName"].Value.Trim(); statistics.Path = string.Join("/", statistics.ToolId, statistics.ToolVersion, statistics.FileName); return(statistics); } return(null); }