コード例 #1
0
        public void MakesNoChangeIfThereAreNoLinks()
        {
            const string html      = @"<div><a>abc</a></div>";
            var          rewriter  = new HtmlAgilityRelativeUrlRewriter();
            var          rewritten = rewriter.RewriteRelativeUrls(html, "/prefix");

            Assert.IsTrue(string.Equals(rewritten, html));
        }
コード例 #2
0
        public void IgnoresProtocolAgnosticUrls()
        {
            const string html      = @"<div><a href=""/a/b"">test</a></div><a href=""//b/c"">test2</a>";
            var          rewriter  = new HtmlAgilityRelativeUrlRewriter();
            var          rewritten = rewriter.RewriteRelativeUrls(html, "/prefix");

            Assert.IsTrue(string.Equals(rewritten, @"<div><a href=""/prefix/a/b"">test</a></div><a href=""//b/c"">test2</a>"));
        }
コード例 #3
0
        public void AddsPrefixToRelativeUrls()
        {
            const string html      = @"<div><a href=""/a/b"">test</a></div><A href=""/b/c"">test2</A>";
            var          rewriter  = new HtmlAgilityRelativeUrlRewriter();
            var          rewritten = rewriter.RewriteRelativeUrls(html, "/prefix");

            //Note - tag names all become lowercase.
            Assert.IsTrue(string.Equals(rewritten, @"<div><a href=""/prefix/a/b"">test</a></div><a href=""/prefix/b/c"">test2</a>"));
        }