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);
                    }
                }
            }
        }
Exemple #2
0
        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());
        }
Exemple #3
0
        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());
        }
Exemple #4
0
        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());
        }
Exemple #5
0
        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());
        }
Exemple #6
0
        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());
        }
Exemple #7
0
        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());
        }
Exemple #8
0
        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());
        }
Exemple #9
0
        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());
        }
Exemple #10
0
        public void ParseCanHandleRelativePathsWithoutExtension()
        {
            var builder = UrlParts.Parse(serverUtil, "home/index/state");

            Assert.AreEqual("home/index/state", builder.BuildPath());
        }
Exemple #11
0
        public void ParseCanHandleRelativePathsWithEmptyPathInfo()
        {
            var builder = UrlParts.Parse(serverUtil, "home/index.ext/");

            Assert.AreEqual("home/index.ext", builder.BuildPath());
        }