Skip to content

Commit cbd4dc6

Browse files
authored
Handle "all slashes" routes (#17596)
1 parent 9febbc7 commit cbd4dc6

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

src/Umbraco.Core/Routing/UriUtility.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,12 @@ public Uri UriToUmbraco(Uri uri)
111111
if (path != "/")
112112
{
113113
path = path.TrimEnd(Constants.CharArrays.ForwardSlash);
114+
115+
// perform fallback to root if the path was all slashes (i.e. https://some.where//////)
116+
if (path == string.Empty)
117+
{
118+
path = "/";
119+
}
114120
}
115121

116122
return uri.Rewrite(path);

tests/Umbraco.Tests.UnitTests/Umbraco.Core/Routing/UriUtilityTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ public class UriUtilityTests
2323

2424
// test that the trailing slash goes but not on hostname
2525
[TestCase("http://LocalHost/", "http://localhost/")]
26+
[TestCase("http://LocalHost/////", "http://localhost/")]
2627
[TestCase("http://LocalHost/Home/", "http://localhost/home")]
28+
[TestCase("http://LocalHost/Home/////", "http://localhost/home")]
2729
[TestCase("http://LocalHost/Home/?x=y", "http://localhost/home?x=y")]
2830
[TestCase("http://LocalHost/Home/Sub1/", "http://localhost/home/sub1")]
2931
[TestCase("http://LocalHost/Home/Sub1/?x=y", "http://localhost/home/sub1?x=y")]

0 commit comments

Comments
 (0)