/**************************************************************************/ private string ProcessCssBackImageUrl(string BackgroundImageUrl) { string LinkUrlAbs = null; string LinkUrlCleaned = MacroscopeHttpUrlUtils.CleanUrlCss(BackgroundImageUrl); if (LinkUrlCleaned != null) { try { LinkUrlAbs = MacroscopeHttpUrlUtils.MakeUrlAbsolute( BaseUrl: this.DocUrl, Url: LinkUrlCleaned ); } catch (MacroscopeUriFormatException ex) { DebugMsg(string.Format("ProcessCssBackImageUrl: {0}", ex.Message)); } DebugMsg(string.Format("ProcessCssBackImageUrl: {0}", LinkUrlCleaned)); DebugMsg(string.Format("ProcessCssBackImageUrl: this.DocUrl: {0}", this.DocUrl)); DebugMsg(string.Format("ProcessCssBackImageUrl: LinkUrlAbs: {0}", LinkUrlAbs)); } return(LinkUrlAbs); }
public void TestCleanUrlCss() { Dictionary <string, string> PropertiesTable = new Dictionary <string, string> (); PropertiesTable.Add( "background-image:none;", null ); PropertiesTable.Add( "background: #0b7bee url(none) no-repeat center center/cover;", null ); PropertiesTable.Add( "background: #0b7bee url(images/video-bg.jpg) no-repeat center center/cover;", "images/video-bg.jpg" ); PropertiesTable.Add( "background: #0b7bee url(\"images/video-bg.jpg\") no-repeat center center/cover;", "images/video-bg.jpg" ); PropertiesTable.Add( "src: url(\"fonts/company/latin-e-bold-eot.eot\");", "fonts/company/latin-e-bold-eot.eot" ); PropertiesTable.Add( "src: url(\"fonts/company/latin-e-bold-eot.eot?#iefix\") format(\"embedded-opentype\"),url(\"fonts/company/latin-e-bold-woff.woff\") format(\"woff\"),url(\"fonts/company/latin-e-bold-ttf.ttf\") format(\"truetype\");", "fonts/company/latin-e-bold-eot.eot?#iefix" ); PropertiesTable.Add( "background: #ffffff url(images/services/features-background.png) no-repeat left bottom;", "images/services/features-background.png" ); PropertiesTable.Add( "background: transparent url(\"images/home/mouse.png\") no-repeat 90% top;", "images/home/mouse.png" ); PropertiesTable.Add( "background: #0b7bee url(images/services/features-background_hover.png) no-repeat left bottom;", "images/services/features-background_hover.png" ); PropertiesTable.Add( "background-image: url(\"images/global/page-head-trans.png\");", "images/global/page-head-trans.png" ); PropertiesTable.Add( "background-image: url(\"images/heroes/hero.jpg\");", "images/heroes/hero.jpg" ); foreach (string PropertyKey in PropertiesTable.Keys) { string Cleaned = MacroscopeHttpUrlUtils.CleanUrlCss(PropertyKey); Assert.AreEqual(PropertiesTable[PropertyKey], Cleaned, string.Format("NOT VALID: {0}", Cleaned)); } }