private void CreateUrlPartBuilder() { var urlParams = urlParam as IDictionary; if (urlParams != null) { urlParams["encode"] = "true"; var urlBuilder = EngineContext.Services.GetService <IUrlBuilder>(); urlParts = urlBuilder.CreateUrlPartsBuilder(EngineContext.UrlInfo, urlParams); } else { if (urlParam != null) { urlParts = UrlParts.Parse(EngineContext.Server, urlParam.ToString()); } else { if (!PreserveQueryString) { urlParts = new UrlParts(EngineContext.Server, EngineContext.Request.FilePath); } else { urlParts = UrlParts.Parse(EngineContext.Server, EngineContext.Request.Url); } } } }
public void ParseCanHandleEscapedQueryStringParameters() { var builder = UrlParts.Parse(serverUtil, "home/index.ext?date=01%2f01%2f2001"); Assert.AreEqual("01/01/2001", builder.QueryString["date"]); Assert.AreEqual("home/index.ext?date=01%2f01%2f2001", builder.BuildPath()); }
public void ParseCanHandleAbsolutePaths() { var builder = UrlParts.Parse(serverUtil, "http://localhost/home/index.ext"); Assert.AreEqual(0, builder.PathInfoDict.Count); Assert.AreEqual("http://localhost/home/index.ext", builder.BuildPath()); }
public void ParseCanHandleRelativePathsWithEmptyPathInfoAndQueryString() { var builder = UrlParts.Parse(serverUtil, "home/index.ext/?id=1&name=john"); Assert.AreEqual(0, builder.PathInfoDict.Count); Assert.AreEqual("id=1&name=john", builder.QueryStringAsString()); Assert.AreEqual("home/index.ext?id=1&name=john", builder.BuildPath()); }
public void ParseCanHandleAbsolutePathsWithQueryString() { var builder = UrlParts.Parse(serverUtil, "http://localhost/home/index.ext?id=1&type=home"); Assert.AreEqual(0, builder.PathInfoDict.Count); Assert.AreEqual("id=1&type=home", builder.QueryStringAsString()); Assert.AreEqual("http://localhost/home/index.ext?id=1&type=home", builder.BuildPath()); }
public void ParseCanHandleRelativePathsWithoutExtensionAndQueryStringContainingDot() { var builder = UrlParts.Parse(serverUtil, "home/index/state?file=index.pdf"); Assert.AreEqual(0, builder.PathInfoDict.Count); Assert.AreEqual("file=index.pdf", builder.QueryStringAsString()); Assert.AreEqual("index.pdf", builder.QueryString["file"]); Assert.AreEqual("home/index/state?file=index.pdf", builder.BuildPath()); }
public void ParseCanHandleRelativePathsWithoutExtensionAndQueryString() { var builder = UrlParts.Parse(serverUtil, "home/index/state?id=1"); Assert.AreEqual(0, builder.PathInfoDict.Count); Assert.AreEqual("id=1", builder.QueryStringAsString()); Assert.AreEqual("1", builder.QueryString["id"]); Assert.AreEqual("home/index/state?id=1", builder.BuildPath()); }
public void ParseCanHandleRelativePathsWithPathInfo2() { var builder = UrlParts.Parse(serverUtil, "home/index.ext/state/fl/"); Assert.AreEqual(1, builder.PathInfoDict.Count); Assert.AreEqual("fl", builder.PathInfoDict["state"]); Assert.IsNull(builder.QueryStringAsString()); Assert.AreEqual("home/index.ext/state/fl", builder.BuildPath()); }
public void ParseCanHandleAbsolutePathsWithPathInfo() { var builder = UrlParts.Parse(serverUtil, "http://localhost/home/index.ext/state/fl/"); Assert.AreEqual(1, builder.PathInfoDict.Count); Assert.AreEqual("fl", builder.PathInfoDict["state"]); Assert.AreEqual("", builder.QueryStringAsString()); Assert.AreEqual("http://localhost/home/index.ext/state/fl", builder.BuildPath()); }
public void ParseCanHandleRelativePathsWithoutExtension() { var builder = UrlParts.Parse(serverUtil, "home/index/state"); Assert.AreEqual("home/index/state", builder.BuildPath()); }
public void ParseCanHandleRelativePathsWithEmptyPathInfo() { var builder = UrlParts.Parse(serverUtil, "home/index.ext/"); Assert.AreEqual("home/index.ext", builder.BuildPath()); }