public void AddPathWithParamsEnsuresSlashAreNotRepeated() { // Arrange var pagePath = "~/dir/page/"; // Act var builder = new UrlBuilder(GetContext(), _virtualPathUtility, pagePath, null); builder.AddPath("foo", "/bar/", "/baz").AddPath("qux/"); // Assert Assert.Equal("dir/page/foo/bar/baz/qux/", builder.Path); }
public void AddPathEncodesPathParams() { // Arrange var pagePath = "~/dir/page?someparam=value"; // Act var builder = new UrlBuilder(GetContext(), _virtualPathUtility, pagePath, null); builder.AddPath("foo bar").AddPath("baz biz", "qux"); // Assert Assert.Equal("dir/page/foo%20bar/baz%20biz/qux", builder.Path); }
public void AddPathWithParamsArrayAddsPathPortionToAbsoluteUrl() { // Arrange var pagePath = "http://www.test.com/dir/page/?someparam=value"; // Act var builder = new UrlBuilder(GetContext(), _virtualPathUtility, pagePath, null); builder.AddPath("foo", "bar", "baz").AddPath("qux"); // Assert Assert.Equal("http://www.test.com/dir/page/foo/bar/baz/qux", builder.Path); Assert.Equal("?someparam=value", builder.QueryString); }
public void AddPathAddsPathPortionToAbsoluteUrl() { // Arrange var pagePath = "http://some-site/dir/page?someparam=value"; // Act var builder = new UrlBuilder(GetContext(), _virtualPathUtility, pagePath, null); builder.AddPath("foo").AddPath("bar/baz"); // Assert Assert.Equal("http://some-site/dir/page/foo/bar/baz", builder.Path); Assert.Equal("?someparam=value", builder.QueryString); }
/// <summary> /// Returns an object URL with the given selector. /// </summary> public UrlBuilder GetPathUrl(string repositoryId, string path) { String url = GetRootUrl(repositoryId); if (url == null) { return(null); } UrlBuilder result = new UrlBuilder(url); result.AddPath(path); return(result); }