public MatchedUrl FindBaseUrl(string urlToMatch) { urlToMatch = urlToMatch.ToLower().Trim('/'); var pathCount = PathMatcher.Match(urlToMatch).Groups["Path"].Captures.Count; if (!Urls.ContainsKey(pathCount)) { return(MatchedUrl.FailedMatch()); } return(Urls[pathCount].FindBaseUrl(urlToMatch)); }
public MatchedUrl FindBaseUrl(string urlToMatch) { var maxWildcardCount = Urls.Keys.Max(); for (var x = 0; x <= maxWildcardCount; x++) { if (!Urls.ContainsKey(x)) { continue; } var cutUrlToMatch = CutPathFromUrl(urlToMatch, x); var matchedUrl = Urls[x].FirstOrDefault(url => url.UrlWithoutWildcards == cutUrlToMatch); if (matchedUrl != null) { return(new MatchedUrl(matchedUrl, GetQueryStringPairs(matchedUrl, urlToMatch))); } } return(MatchedUrl.FailedMatch()); }