private bool IsActive(TagHelperAttribute href) { var hrefPath = Pathy.Normalize(href.Value.ToString()); var currentPath = ViewContext.HttpContext.Request.Path.Value; if (!hrefPath.Equals("/", comparison)) { return(currentPath.StartsWith(hrefPath, comparison)); } return(currentPath.Equals("/", comparison)); }
public void NormalizingRelativePath() { var result = Pathy.Normalize("..\\\\test.txt"); result.Should().Be("../test.txt"); }
public void NormalizingAbsoluteUrl() { var result = Pathy.Normalize("http:\\\\www.web.cz\\"); result.Should().Be("http://www.web.cz/"); }
public void NormalizingAbsolutePath() { var result = Pathy.Normalize("c:\\test\\\\test.txt"); result.Should().Be("c:/test/test.txt"); }
public void MakingRelativePathAbsolute() { var result = Pathy.MakeAbsolute("c:/test", "test.txt"); result.Should().Be("c:/test.txt"); }
public void MakingAbsolutePathRelativeToRoot() { var result = Pathy.MakeRelativeToRoot("c:/test/", "c:/test/neco/test.txt"); result.Should().Be("/neco/test.txt"); }
public void MakingAbsolutePathAbsolute() { var result = Pathy.MakeAbsolute("c:/anyabsolute.txt", "c:/test.txt"); result.Should().Be("c:/test.txt"); }
public void CheckingWhetherAbsoluteUrlIsAbsolute() { var result = Pathy.IsAbsolutePath("http://test.cz/"); result.Should().BeTrue(); }
public void CheckingWhetherAbsolutePathIsAbsolute() { var result = Pathy.IsAbsolutePath("c:/test.txt"); result.Should().BeTrue(); }
public void AppendingTrailingSlashToEmptyString() { var result = Pathy.AppendTrailingSlash(string.Empty); result.Should().Be("/"); }
public void AppendingTrailingSlash() { var result = Pathy.AppendTrailingSlash("/test/result"); result.Should().Be("/test/result/"); }
public void RemovingTrailingSlashFromEmptyString() { var result = Pathy.RemoveTrailingSlash(string.Empty); result.Should().Be(string.Empty); }
public void RemovingTrailingSlash() { var result = Pathy.RemoveTrailingSlash("/test/result/"); result.Should().Be("/test/result"); }
public void RemovingLeadingSlash() { var result = Pathy.RemoveLeadingSlash("/test/result"); result.Should().Be("test/result"); }
public void CheckingWhetherRelativePathIsAbsolute(string relative) { var result = Pathy.IsAbsolutePath(relative); result.Should().BeFalse(); }