diff --git a/src/Microsoft.Owin.StaticFiles/DefaultFilesMiddleware.cs b/src/Microsoft.Owin.StaticFiles/DefaultFilesMiddleware.cs index e4d9783a..52f575b2 100644 --- a/src/Microsoft.Owin.StaticFiles/DefaultFilesMiddleware.cs +++ b/src/Microsoft.Owin.StaticFiles/DefaultFilesMiddleware.cs @@ -70,7 +70,7 @@ namespace Microsoft.Owin.StaticFiles string defaultFile = _options.DefaultFileNames[matchIndex]; IFileInfo file; // TryMatchPath will make sure subpath always ends with a "/" by adding it if needed. - if (_options.FileSystem.TryGetFileInfo(subpath + defaultFile, out file)) + if (_options.FileSystem.TryGetFileInfo(subpath.Value + defaultFile, out file)) { // If the path matches a directory but does not end in a slash, redirect to add the slash. // This prevents relative links from breaking. diff --git a/tests/Microsoft.Owin.StaticFiles.Tests/DefaultFilesMiddlewareTests.cs b/tests/Microsoft.Owin.StaticFiles.Tests/DefaultFilesMiddlewareTests.cs index 644d924d..3c67cf60 100644 --- a/tests/Microsoft.Owin.StaticFiles.Tests/DefaultFilesMiddlewareTests.cs +++ b/tests/Microsoft.Owin.StaticFiles.Tests/DefaultFilesMiddlewareTests.cs @@ -61,6 +61,8 @@ namespace Microsoft.Owin.StaticFiles.Tests [InlineData("", @".\", "/SubFolder/")] [InlineData("", @"SubFolder", "/")] [InlineData("", @".\SubFolder", "/")] + [InlineData("", @"./SubFolder", "/你好/")] + [InlineData("", @"./SubFolder", "/你好/世界/")] public void FoundDirectoryWithDefaultFile_PathModified(string baseUrl, string baseDir, string requestUrl) { IAppBuilder builder = new AppBuilder(); diff --git a/tests/Microsoft.Owin.StaticFiles.Tests/Microsoft.Owin.StaticFiles.Tests.csproj b/tests/Microsoft.Owin.StaticFiles.Tests/Microsoft.Owin.StaticFiles.Tests.csproj index f4df85fc..81d892df 100644 --- a/tests/Microsoft.Owin.StaticFiles.Tests/Microsoft.Owin.StaticFiles.Tests.csproj +++ b/tests/Microsoft.Owin.StaticFiles.Tests/Microsoft.Owin.StaticFiles.Tests.csproj @@ -108,6 +108,12 @@ PreserveNewest + + PreserveNewest + + + PreserveNewest + PreserveNewest diff --git a/tests/Microsoft.Owin.StaticFiles.Tests/SubFolder/你好/Default.html b/tests/Microsoft.Owin.StaticFiles.Tests/SubFolder/你好/Default.html new file mode 100644 index 00000000..4740d836 --- /dev/null +++ b/tests/Microsoft.Owin.StaticFiles.Tests/SubFolder/你好/Default.html @@ -0,0 +1,11 @@ + + + + + + + + + Hello World + + \ No newline at end of file diff --git a/tests/Microsoft.Owin.StaticFiles.Tests/SubFolder/你好/世界/Default.html b/tests/Microsoft.Owin.StaticFiles.Tests/SubFolder/你好/世界/Default.html new file mode 100644 index 00000000..4740d836 --- /dev/null +++ b/tests/Microsoft.Owin.StaticFiles.Tests/SubFolder/你好/世界/Default.html @@ -0,0 +1,11 @@ + + + + + + + + + Hello World + + \ No newline at end of file