Example #1
0
        public void TestGetTitleFromUri()
        {
            const string testUri = "http://www.google.com";
            string       result  = UrlUtility.GetTitleFromUri(testUri);

            Assert.AreEqual("Google", result, "Unable to extract title from given Uri.");
        }
Example #2
0
        public void TestTagInTitle()
        {
            Uri testUri = new Uri("http://stackoverflow.com/questions/1348683/will-the-b-and-i-tags-ever-become-deprecated");

            string result = UrlUtility.GetTitleFromUri(testUri.ToString());

            Assert.AreEqual("Will the <b> and <i> tags ever become deprecated?", result, "HTML in title not properly decoded");
        }
Example #3
0
        public void TestEscapedQuotesInTitle()
        {
            Uri testUri = new Uri("https://lwn.net/Articles/653411/");

            string result = UrlUtility.GetTitleFromUri(testUri.ToString());

            Assert.AreEqual("\"Big data\" features coming in PostgreSQL 9.5 [LWN.net]", result, "HTML in title not properly decoded");
        }
Example #4
0
        public JsonResult TitleFromUri()
        {
            var    uri   = Request.Params["uri"];
            string title = UrlUtility.GetTitleFromUri(uri);

            if (title != null)
            {
                var resultList = new List <string>
                {
                    title
                };

                return(Json(resultList, JsonRequestBehavior.AllowGet));
            }

            Response.StatusCode = (int)HttpStatusCode.BadRequest;
            return(Json("Bad request.", JsonRequestBehavior.AllowGet));
        }
Example #5
0
        public string TitleFromUri()
        {
            var uri = Request.Params["uri"];

            return(UrlUtility.GetTitleFromUri(uri));
        }