public async Task <CombResponse> Brush(CombRequest request) { var response = Validate(request, new CombResponse()); if (!response.Success) { return(response); } var urlDomain = GetUrlDomain(request); var link = new CombLink(request.Url, urlDomain); await Brush(link, urlDomain, request.Depth); response.Result = link; return(response); }
private CombResponse Validate(CombRequest request, CombResponse response) { try { if (string.IsNullOrEmpty(request.Url) || !request.Url.StartsWith(Uri.UriSchemeHttp) || !Uri.IsWellFormedUriString(request.Url, UriKind.RelativeOrAbsolute) || string.IsNullOrEmpty(GetUrlDomain(request))) { response.Errors.Add("Invalid Url"); } } catch { response.Errors.Add("Invalid Url"); } return(response); }
private string GetUrlDomain(CombRequest request) { return(new Uri(request.Url).GetLeftPart(UriPartial.Authority)); }