public void ToAbsolute8_b() { Assert.AreEqual("/blah2/", VPU.ToAbsolute("/blah1/../blah2/")); Assert.AreEqual("/blah2/", VPU.ToAbsolute("/blah1//../blah2/")); Assert.AreEqual("/blah2/", VPU.ToAbsolute("/blah1/\\../blah2/")); Assert.AreEqual("/blah2/", VPU.ToAbsolute("/blah1\\\\../blah2/")); Assert.AreEqual("/blah1/blah2/", VPU.ToAbsolute("/blah1/./blah2/")); }
public static IHtmlString StyleBundle(this HtmlHelper helper, string bundleKey) { if (helper == null) { throw new ArgumentNullException("helper"); } if (String.IsNullOrEmpty(bundleKey)) { throw new ArgumentNullException("bundleKey"); } var context = helper.ViewContext.HttpContext; if (!CssBundleManager.IsEnabled) { StringBuilder sb = new StringBuilder(); foreach (var include in CssBundleManager.GetBundleIncludes(bundleKey)) { var cssUrl = include; if (string.IsNullOrEmpty(cssUrl)) { continue; } if (cssUrl != null && cssUrl.StartsWith("dynamic://", StringComparison.OrdinalIgnoreCase)) { var scriptName = cssUrl.Substring(10); cssUrl = DynamicScriptManager.GetScriptInclude(scriptName, ".css"); cssUrl = VirtualPathUtility.ToAbsolute("~/DynJS.axd/" + cssUrl); } else { cssUrl = BundleUtils.ExpandVersionVariable(cssUrl); cssUrl = VirtualPathUtility.ToAbsolute(cssUrl); } var cssList = GetIncludedCssList(context); if (!cssList.Contains(cssUrl)) { cssList.Add(cssUrl); sb.AppendLine(String.Format(" <link href=\"{0}\" rel=\"stylesheet\" type=\"text/css\"/>\n", #if !ASPNETMVC WebUtility.HtmlEncode(ContentHashCache.ResolveWithHash(cssUrl)))); #else HttpUtility.HtmlAttributeEncode(ContentHashCache.ResolveWithHash(cssUrl)))); #endif } } return(new HtmlString(sb.ToString())); } return(Stylesheet(helper, "dynamic://CssBundle." + bundleKey)); }
public static IHtmlString ScriptBundle(this HtmlHelper helper, string bundleKey) { if (helper == null) { throw new ArgumentNullException("helper"); } if (String.IsNullOrEmpty(bundleKey)) { throw new ArgumentNullException("bundleKey"); } var context = helper.ViewContext.HttpContext; if (!ScriptBundleManager.IsEnabled) { StringBuilder sb = new StringBuilder(); foreach (var include in ScriptBundleManager.GetBundleIncludes(bundleKey)) { var scriptUrl = include; if (string.IsNullOrEmpty(scriptUrl)) { continue; } if (scriptUrl != null && scriptUrl.StartsWith("dynamic://", StringComparison.OrdinalIgnoreCase)) { var scriptName = scriptUrl.Substring(10); scriptUrl = DynamicScriptManager.GetScriptInclude(scriptName); scriptUrl = VirtualPathUtility.ToAbsolute("~/DynJS.axd/" + scriptUrl); } else { scriptUrl = BundleUtils.ExpandVersionVariable(scriptUrl); scriptUrl = VirtualPathUtility.ToAbsolute(scriptUrl); } var scripts = GetIncludedScripts(context); if (!scripts.Contains(scriptUrl)) { scripts.Add(scriptUrl); sb.AppendLine(String.Format(" <script src=\"{0}\" type=\"text/javascript\"></script>\n", #if !ASPNETMVC WebUtility.HtmlEncode(ContentHashCache.ResolveWithHash(scriptUrl)))); #else HttpUtility.HtmlAttributeEncode(ContentHashCache.ResolveWithHash(scriptUrl)))); #endif } } return(new HtmlString(sb.ToString())); } return(Script(helper, "dynamic://Bundle." + bundleKey)); }
public void ToAbsolute8_a() { Assert.AreEqual("/blah2/", VPU.ToAbsolute("/blah1/../blah2/", "/ROOT")); Assert.AreEqual("/blah2/", VPU.ToAbsolute("/blah1//../blah2/", "/ROOT")); Assert.AreEqual("/blah2/", VPU.ToAbsolute("/blah1/\\../blah2/", "/ROOT")); Assert.AreEqual("/blah2/", VPU.ToAbsolute("/blah1\\\\../blah2/", "/ROOT")); Assert.AreEqual("/blah1/blah2/", VPU.ToAbsolute("/blah1/./blah2/", "/ROOT")); Assert.AreEqual("/blah1", VPU.ToAbsolute("/blah1/blah2/..", "/ROOT")); Assert.AreEqual("/", VPU.ToAbsolute("/blah1/..", "/ROOT")); Assert.AreEqual("/blah1/", VPU.ToAbsolute("/blah1/blah2/../", "/ROOT")); Assert.AreEqual("/", VPU.ToAbsolute("/blah1/../", "/ROOT")); Assert.AreEqual("/blah1", VPU.ToAbsolute("/blah1/.", "/ROOT")); Assert.AreEqual("/", VPU.ToAbsolute("/.", "/ROOT")); Assert.AreEqual("/blah1/", VPU.ToAbsolute("/blah1/./", "/ROOT")); Assert.AreEqual("/", VPU.ToAbsolute("/./", "/ROOT")); }
public void ToAbsolute13() { Assert.AreEqual("/blah", VPU.ToAbsolute("/blah", "ROOT")); }
public void ToAbsolute12() { VPU.ToAbsolute("~/blah", "ROOT"); }
public void ToAbsolute11() { VPU.ToAbsolute("blah", "/ROOT"); }
public void ToAbsolute10() { VPU.ToAbsolute("../blah", "/ROOT"); }
public void ToAbsolute9() { Assert.AreEqual("/ROOT/", VPU.ToAbsolute("~", "/ROOT")); Assert.AreEqual("/ROOT/", VPU.ToAbsolute("~/", "/ROOT")); Assert.AreEqual("/ROOT/blah", VPU.ToAbsolute("~/blah", "/ROOT/")); }
public void ToAbsolute8() { Assert.AreEqual("/", VPU.ToAbsolute("/", "/ROOT")); Assert.AreEqual("/blah/blah/", VPU.ToAbsolute("/blah//blah//", "/ROOT")); Assert.AreEqual("/blah/blah/", VPU.ToAbsolute("/blah\\blah/", "/ROOT")); }
public static void ToAbsolute7_Load(Page p) { Assert.AreEqual("/", VPU.ToAbsolute("/")); Assert.AreEqual("/", VPU.ToAbsolute("//")); }
public static void ToAbsolute6_Load(Page p) { Assert.AreEqual("/" + NunitWebAppName + "/", VPU.ToAbsolute("~/")); Assert.AreEqual("/" + NunitWebAppName, VPU.ToAbsolute("~")); }
public static void ToAbsolute5_Load(Page p) { VPU.ToAbsolute("../blah"); }
public static void ToAbsolute4_Load(Page p) { VPU.ToAbsolute("..."); }
public static void ToAbsolute2_Load(Page p) { VPU.ToAbsolute(""); }
public static void ToAbsolute1_Load(Page p) { VPU.ToAbsolute(null); }