Ejemplo n.º 1
0
        public IEnumerable <CharsetSearchResultPerDomain> GetRanking(int skipCount, int takeCount)
        {
            var policeMan = new CharsetPoliceMan();
            var ranking   = policeMan.BuildRanking(store.Values);

            return(ranking.Skip(skipCount)
                   .Take(takeCount));
        }
Ejemplo n.º 2
0
        public void TestSearchBe()
        {
            var policeMan = new CharsetPoliceMan();
            var body      = "<html><head><meta charset=\"utf-16\"></head>";

            var expected = 36;
            var actual   = policeMan.SearchCharset(Encoding.BigEndianUnicode.GetBytes(body));

            Assert.AreEqual(expected, actual, "charsetが含まれている。");
        }
Ejemplo n.º 3
0
        public void TestSearchCharsetUppercase()
        {
            var policeMan = new CharsetPoliceMan();
            var body      = "<HTML><HEAD><META CHARSET=\"UTF-8\"></HEAD>";

            // 当面大文字は無視
            //var expected = 18;
            var expected = -1;
            var actual   = policeMan.SearchCharset(Encoding.UTF8.GetBytes(body));

            Assert.AreEqual(expected, actual, "CHARSETが含まれているが対象外。");
        }
Ejemplo n.º 4
0
        public static async Task <IActionResult> RunAsync(
            [HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = "charset-police")] CharsetPoliceRequest req,
            ILogger log)
        {
            log.LogInformation("C# HTTP trigger function processed a request.");
            log.LogInformation($"Request URI: {req.Uri}");

            var policeMan = new CharsetPoliceMan();
            var result    = await policeMan.SearchAsync(new Uri(req.Uri));

            return(new OkObjectResult(result));
        }
Ejemplo n.º 5
0
        public async Task <ActionResult> Create(InvestigationRequest request)
        {
            try
            {
                var policeMan = new CharsetPoliceMan();
                var result    = await policeMan.SearchAsync(request.Uri);

                investigationRepository.Put(result);

                return(RedirectToAction(nameof(Details), new { uri = request.Uri.ToString() }));
            }
            catch
            {
                return(View("Views/Home/Index.cshtml"));
            }
        }