Пример #1
0
        TestExpandUrl6()
        {
            // No such page.

            Assert.AreEqual("http://www.ThereIsNoSuchAddressAsThis.com",
                            UrlUtil.ExpandUrl("http://www.ThereIsNoSuchAddressAsThis.com"));
        }
Пример #2
0
        TestExpandUrl5()
        {
            // Real page.

            Assert.AreEqual("http://www.bing.com",
                            UrlUtil.ExpandUrl("http://www.bing.com"));
        }
Пример #3
0
        GetUrlsFromStatusValueDictionary
        (
            Dictionary <String, Object> statusValueDictionary,
            Boolean expandUrls
        )
        {
            Debug.Assert(statusValueDictionary != null);

            Dictionary <String, Object> entityValueDictionary;

            if (!TryGetEntityValueDictionary(statusValueDictionary,
                                             out entityValueDictionary))
            {
                return(new String[0]);
            }

            String [] urls = GetEntities(
                entityValueDictionary, "urls", "expanded_url", false);

            if (expandUrls)
            {
                Int32 urlCount = urls.Length;

                for (Int32 i = 0; i < urlCount; i++)
                {
                    // If there is an (illegal) space in the expanded URL, escape
                    // it to prevent it from causing problems further down the
                    // line.

                    urls[i] = UrlUtil.ExpandUrl(urls[i]).Replace(" ", "%20");
                }
            }

            return(urls);
        }
Пример #4
0
        TestExpandUrl10()
        {
            // Bad URL found on Twitter on 5/28/2013.

            const String Url = "twitter.com/nsm";

            Assert.AreEqual(Url, UrlUtil.ExpandUrl(Url));
        }
Пример #5
0
        TestExpandUrl7()
        {
            // Real page, slow.

            Assert.AreEqual(
                "https://nodexlgraphgallery.org/Pages/Graph.aspx?graphID=718",
                UrlUtil.ExpandUrl("http://bit.ly/KFlexu"));
        }
Пример #6
0
        TestExpandUrl9()
        {
            // Real page, Location header is relative URL instead of the required
            // absolute URL.

            const String Url =
                "http://www.marketwatch.com/Story/story/rescue?SourceUrl=http://www.marketwatch.com/story/hispanic-national-bar-association-statement-on-state-of-the-union-address-2012-01-26";

            Assert.AreEqual(Url, UrlUtil.ExpandUrl(Url));
        }
Пример #7
0
        TestExpandUrl8()
        {
            // Repeated calls.

            for (Int32 i = 0; i < 10; i++)
            {
                Assert.AreEqual("http://en.wikipedia.org/wiki/URL_shortening",
                                UrlUtil.ExpandUrl("http://bit.ly/urlwiki"));

                Assert.AreEqual("http://en.wikipedia.org/wiki/URL_shortening",
                                UrlUtil.ExpandUrl("http://tinyurl.com/urlwiki"));

                Assert.AreEqual("http://en.wikipedia.org/wiki/URL_shortening",
                                UrlUtil.ExpandUrl("http://is.gd/urlwiki"));

                Assert.AreEqual("http://en.wikipedia.org/wiki/URL_shortening",
                                UrlUtil.ExpandUrl("http://goo.gl/Gmzqv"));

                Assert.AreEqual("http://www.bing.com",
                                UrlUtil.ExpandUrl("http://www.bing.com"));
            }
        }
Пример #8
0
 TestExpandUrl2()
 {
     Assert.AreEqual("http://en.wikipedia.org/wiki/URL_shortening",
                     UrlUtil.ExpandUrl("http://tinyurl.com/urlwiki"));
 }
Пример #9
0
 TestExpandUrl()
 {
     Assert.AreEqual("http://en.wikipedia.org/wiki/URL_shortening",
                     UrlUtil.ExpandUrl("http://bit.ly/urlwiki"));
 }
Пример #10
0
 TestExpandUrl4()
 {
     Assert.AreEqual("http://en.wikipedia.org/wiki/URL_shortening",
                     UrlUtil.ExpandUrl("http://goo.gl/Gmzqv"));
 }