public static string GetCss(Uri baseuri) { StringBuilder css = new StringBuilder(); css.AppendLine("<style type=\"text/css\">"); css.AppendLine("<!--"); css.AppendLine(CssAbsoluteLinksWriter.Rewrite(GetHttpContent(new Uri(baseuri, "Style.css")), baseuri)); css.AppendLine("-->"); css.AppendLine("</style>"); return(css.ToString()); }
public void RewriteRelativeUrls() { string baseuri = "http://www.rewritten.com/"; TestDataItem[] testdata = { new TestDataItem("body: background-color: red;"), new TestDataItem( "background: url(images/site/head.gif) no-repeat;", string.Format("background: url({0}images/site/head.gif) no-repeat;", baseuri)), new TestDataItem( "background: url(http://www.notrewritten.com/images/site/head.gif) no-repeat;") }; foreach (TestDataItem test in testdata) { string output = CssAbsoluteLinksWriter.Rewrite(test._input, new Uri(baseuri, UriKind.Absolute)); Console.WriteLine("{0} => {1}", test._input, output); Assert.AreEqual(test._output, output); } }