Improved file serving to support startPaths. Improved code and simplified a few things. Bumped package version to 1.6.7
This commit is contained in:
@ -46,17 +46,7 @@ namespace Rest.Net.Tests
|
||||
[Fact]
|
||||
public void ServeMultiple_File_ShouldWork()
|
||||
{
|
||||
HttpListenerResponseExtensions.ResolveMultiPagePath(this.BaseDirectory, "/test.html", "index.html", out string resolvedPath, out bool isDirectory).Should().BeTrue();
|
||||
|
||||
isDirectory.Should().BeFalse();
|
||||
|
||||
resolvedPath.Should().BeEquivalentTo(this.TestFile);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ServeMultiple_File_WithParentDirectory_ShouldWork()
|
||||
{
|
||||
HttpListenerResponseExtensions.ResolveMultiPagePath(this.BaseDirectory, "test/test.html", "index.html", out string resolvedPath, out bool isDirectory).Should().BeTrue();
|
||||
HttpListenerResponseExtensions.ResolveMultiPagePath(this.BaseDirectory, null, "/test.html", "index.html", out string resolvedPath, out bool isDirectory).Should().BeTrue();
|
||||
|
||||
isDirectory.Should().BeFalse();
|
||||
|
||||
@ -66,7 +56,7 @@ namespace Rest.Net.Tests
|
||||
[Fact]
|
||||
public void ServeMultiple_Directory_ShouldWork()
|
||||
{
|
||||
HttpListenerResponseExtensions.ResolveMultiPagePath(this.BaseDirectory, "/test2", "index.html", out string resolvedPath, out bool isDirectory).Should().BeTrue();
|
||||
HttpListenerResponseExtensions.ResolveMultiPagePath(this.BaseDirectory, null, "/test2", "index.html", out string resolvedPath, out bool isDirectory).Should().BeTrue();
|
||||
|
||||
isDirectory.Should().BeTrue();
|
||||
|
||||
@ -76,13 +66,13 @@ namespace Rest.Net.Tests
|
||||
[Fact]
|
||||
public void ServeMultiple_NavigatingUp_Should_NotWork()
|
||||
{
|
||||
HttpListenerResponseExtensions.ResolveMultiPagePath(this.BaseDirectory, "../test.html", "index.html", out string resolvedPath, out bool isDirectory).Should().BeFalse();
|
||||
HttpListenerResponseExtensions.ResolveMultiPagePath(this.BaseDirectory, null, "../test.html", "index.html", out string resolvedPath, out bool isDirectory).Should().BeFalse();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ServeMultiple_Correct_NavigatingUp_Should_Work()
|
||||
{
|
||||
HttpListenerResponseExtensions.ResolveMultiPagePath(this.BaseDirectory, "a/b/../../test.html", "index.html", out string resolvedPath, out bool isDirectory).Should().BeTrue();
|
||||
HttpListenerResponseExtensions.ResolveMultiPagePath(this.BaseDirectory, null, "a/b/../../test.html", "index.html", out string resolvedPath, out bool isDirectory).Should().BeTrue();
|
||||
|
||||
isDirectory.Should().BeFalse();
|
||||
|
||||
@ -92,13 +82,13 @@ namespace Rest.Net.Tests
|
||||
[Fact]
|
||||
public void ServeMultiple_NavigatingUp_Multiple_Should_NotWork()
|
||||
{
|
||||
HttpListenerResponseExtensions.ResolveMultiPagePath(this.BaseDirectory, "test/../../test.html", "index.html", out string resolvedPath, out bool isDirectory).Should().BeFalse();
|
||||
HttpListenerResponseExtensions.ResolveMultiPagePath(this.BaseDirectory, null, "test/../../test.html", "index.html", out string resolvedPath, out bool isDirectory).Should().BeFalse();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ServeSingle_Empty_Should_Work()
|
||||
{
|
||||
HttpListenerResponseExtensions.ResolveSinglePagePath(this.BaseDirectory, "", "index.html", out string resolvedPath, out bool isDirectory).Should().BeTrue();
|
||||
HttpListenerResponseExtensions.ResolveSinglePagePath(this.BaseDirectory, null, "", "index.html", out string resolvedPath, out bool isDirectory).Should().BeTrue();
|
||||
|
||||
isDirectory.Should().BeFalse();
|
||||
|
||||
@ -108,7 +98,7 @@ namespace Rest.Net.Tests
|
||||
[Fact]
|
||||
public void ServeSingle_File_Should_Work()
|
||||
{
|
||||
HttpListenerResponseExtensions.ResolveSinglePagePath(this.BaseDirectory, "/test.html", "index.html", out string resolvedPath, out bool isDirectory).Should().BeTrue();
|
||||
HttpListenerResponseExtensions.ResolveSinglePagePath(this.BaseDirectory, null, "/test.html", "index.html", out string resolvedPath, out bool isDirectory).Should().BeTrue();
|
||||
|
||||
isDirectory.Should().BeFalse();
|
||||
|
||||
@ -118,7 +108,7 @@ namespace Rest.Net.Tests
|
||||
[Fact]
|
||||
public void ServeSingle_Directory_Should_Work()
|
||||
{
|
||||
HttpListenerResponseExtensions.ResolveSinglePagePath(this.BaseDirectory, "/test2", "index.html", out string resolvedPath, out bool isDirectory).Should().BeTrue();
|
||||
HttpListenerResponseExtensions.ResolveSinglePagePath(this.BaseDirectory, null, "/test2", "index.html", out string resolvedPath, out bool isDirectory).Should().BeTrue();
|
||||
|
||||
isDirectory.Should().BeTrue();
|
||||
|
||||
@ -128,7 +118,7 @@ namespace Rest.Net.Tests
|
||||
[Fact]
|
||||
public void ServeSingle_File_Route_Should_Work()
|
||||
{
|
||||
HttpListenerResponseExtensions.ResolveSinglePagePath(this.BaseDirectory, "/a/b/test.html", "index.html", out string resolvedPath, out bool isDirectory).Should().BeTrue();
|
||||
HttpListenerResponseExtensions.ResolveSinglePagePath(this.BaseDirectory, null, "/a/b/test.html", "index.html", out string resolvedPath, out bool isDirectory).Should().BeTrue();
|
||||
|
||||
isDirectory.Should().BeFalse();
|
||||
|
||||
@ -138,7 +128,7 @@ namespace Rest.Net.Tests
|
||||
[Fact]
|
||||
public void ServeSingle_Directory_Route_Should_Work()
|
||||
{
|
||||
HttpListenerResponseExtensions.ResolveSinglePagePath(this.BaseDirectory, "/a/b/test2", "index.html", out string resolvedPath, out bool isDirectory).Should().BeTrue();
|
||||
HttpListenerResponseExtensions.ResolveSinglePagePath(this.BaseDirectory, null, "/a/b/test2", "index.html", out string resolvedPath, out bool isDirectory).Should().BeTrue();
|
||||
|
||||
isDirectory.Should().BeTrue();
|
||||
|
||||
@ -148,7 +138,7 @@ namespace Rest.Net.Tests
|
||||
[Fact]
|
||||
public void ServeSingle_File_Route_Invalid_Should_Work()
|
||||
{
|
||||
HttpListenerResponseExtensions.ResolveSinglePagePath(this.BaseDirectory, "/a/b/c", "index.html", out string resolvedPath, out bool isDirectory).Should().BeTrue();
|
||||
HttpListenerResponseExtensions.ResolveSinglePagePath(this.BaseDirectory, null, "/a/b/c", "index.html", out string resolvedPath, out bool isDirectory).Should().BeTrue();
|
||||
|
||||
isDirectory.Should().BeFalse();
|
||||
|
||||
@ -158,7 +148,7 @@ namespace Rest.Net.Tests
|
||||
[Fact]
|
||||
public void ServeSingle_File_WithoutExtension_Should_Work()
|
||||
{
|
||||
HttpListenerResponseExtensions.ResolveSinglePagePath(this.BaseDirectory, "/test", "index.html", out string resolvedPath, out bool isDirectory).Should().BeTrue();
|
||||
HttpListenerResponseExtensions.ResolveSinglePagePath(this.BaseDirectory, null, "/test", "index.html", out string resolvedPath, out bool isDirectory).Should().BeTrue();
|
||||
|
||||
isDirectory.Should().BeFalse();
|
||||
|
||||
@ -168,7 +158,17 @@ namespace Rest.Net.Tests
|
||||
[Fact]
|
||||
public void ServeSingle_File_Route_WithoutExtension_Should_Work()
|
||||
{
|
||||
HttpListenerResponseExtensions.ResolveSinglePagePath(this.BaseDirectory, "/a/b/c/test", "index.html", out string resolvedPath, out bool isDirectory).Should().BeTrue();
|
||||
HttpListenerResponseExtensions.ResolveSinglePagePath(this.BaseDirectory, null, "/a/b/c/test", "index.html", out string resolvedPath, out bool isDirectory).Should().BeTrue();
|
||||
|
||||
isDirectory.Should().BeFalse();
|
||||
|
||||
resolvedPath.Should().BeEquivalentTo(this.TestFile);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ServeSingle_File_StartPath_Should_Work()
|
||||
{
|
||||
HttpListenerResponseExtensions.ResolveSinglePagePath(this.BaseDirectory, "/test", "test/test.html", "index.html", out string resolvedPath, out bool isDirectory).Should().BeTrue();
|
||||
|
||||
isDirectory.Should().BeFalse();
|
||||
|
||||
|
Reference in New Issue
Block a user