public ActionResult Check(string str) { var result = CheckKeywords.Check(str); var agent = HttpContext.Request.Headers[HeaderNames.UserAgent][0].ToLower(); if (PLAIN_TEXT_AGENTS.Any(t => agent.Contains(t))) { return(Content(ConvertCLI(result))); } return(new JsonResult(result)); }
private async Task Check() { try { if (string.IsNullOrEmpty(Param)) { return; } if (Uri.IsWellFormedUriString(Param, UriKind.Absolute)) { SwaggerUrl = Param; Param = "loading.."; Param = await Client.GetStringAsync(SwaggerUrl); } Result = CheckKeywords.Check(Param, SelectedLanguageNames.ToList()); if (Result.Result != 1) { var ParamWithTag = Param; var keywords = Result.Items.SelectMany(t => t.Words).Distinct().ToList(); var regTag = Param.Contains("\"") ? "\"" : ",| "; var keywordsStr = string.Join("|", keywords); var regex = $"(?<=({regTag}|^))({keywordsStr})(?=({regTag}|$))"; ParamWithTag = Regex.Replace(ParamWithTag, regex, "<code>$2</code>"); //await JS.InvokeVoidAsync("csfunc.appendHtml", @"AAA", z); ShowResultFragment = true; ResultFragment = (builder) => builder.AddMarkupContent(0, ParamWithTag); } else { ShowResultFragment = false; } } catch (HttpRequestException) { ErrorInfo = "error, please check your swagger url"; Param = SwaggerUrl; SwaggerUrl = string.Empty; Result = new CheckResult { Result = 0 }; } catch (Exception) { Result = new CheckResult { Result = 0 }; } }
private void Check() { try { Result = CheckKeywords.Check(Param); } catch { Result = new CheckResult { Result = 0 }; } }
public void Test1() { var result = CheckKeywords.Check("public,function"); if (result.Result == 3 && result.Items.Any(t => t.Type == 1 && t.Language == "C#") && result.Items.Any(t => t.Type == 2 && t.Language == "javascript") && result.Items.Any(t => t.Type == 1 && t.Language == "javascript")) { Assert.Pass("pass"); } else { Assert.Fail("fail"); } }
public ActionResult Check(string str) { var needCheckValue = Uri.UnescapeDataString(str); if (Uri.IsWellFormedUriString(needCheckValue, UriKind.Absolute)) { var httpClient = new HttpClient(); str = httpClient.GetStringAsync(needCheckValue).Result; } var result = CheckKeywords.Check(str); var agent = HttpContext.Request.Headers[HeaderNames.UserAgent][0].ToLower(); if (PLAIN_TEXT_AGENTS.Any(t => agent.Contains(t))) { return(Content(ConvertCLI(result))); } return(new JsonResult(result)); }
private void Check() { var x = CheckKeywords.Check(param); Result = x; }