diff --git a/SafeExamBrowser.Browser.UnitTests/Filters/Rules/SimplifiedRuleTests.cs b/SafeExamBrowser.Browser.UnitTests/Filters/Rules/SimplifiedRuleTests.cs index c7090331..cfdc2c2e 100644 --- a/SafeExamBrowser.Browser.UnitTests/Filters/Rules/SimplifiedRuleTests.cs +++ b/SafeExamBrowser.Browser.UnitTests/Filters/Rules/SimplifiedRuleTests.cs @@ -265,6 +265,44 @@ namespace SafeExamBrowser.Browser.UnitTests.Filters.Rules Test(expression, positive, negative); } + [TestMethod] + public void TestHostWithTrailingSlash() + { + var expression = "host.org/"; + var positive = new[] + { + "scheme://host.org", + "scheme://host.org/", + "scheme://host.org/url", + "scheme://host.org/url/", + "scheme://host.org/url/path", + "scheme://host.org/url/path/", + "scheme://user:password@www.host.org/url/path?param=123#fragment", + "scheme://user:password@www.host.org/url/path/?param=123#fragment" + }; + + Test(expression, positive, Array.Empty()); + } + + [TestMethod] + public void TestHostWithoutTrailingSlash() + { + var expression = "host.org"; + var positive = new[] + { + "scheme://host.org", + "scheme://host.org/", + "scheme://host.org/url", + "scheme://host.org/url/", + "scheme://host.org/url/path", + "scheme://host.org/url/path/", + "scheme://user:password@www.host.org/url/path?param=123#fragment", + "scheme://user:password@www.host.org/url/path/?param=123#fragment" + }; + + Test(expression, positive, Array.Empty()); + } + [TestMethod] public void TestPortNumber() { diff --git a/SafeExamBrowser.Browser/Filters/Rules/SimplifiedRule.cs b/SafeExamBrowser.Browser/Filters/Rules/SimplifiedRule.cs index 25b07c02..e751cdd4 100644 --- a/SafeExamBrowser.Browser/Filters/Rules/SimplifiedRule.cs +++ b/SafeExamBrowser.Browser/Filters/Rules/SimplifiedRule.cs @@ -118,7 +118,7 @@ namespace SafeExamBrowser.Browser.Filters.Rules private void ParsePath(string expression) { - if (!string.IsNullOrWhiteSpace(expression)) + if (!string.IsNullOrWhiteSpace(expression) && !expression.Equals("/")) { expression = Regex.Escape(expression); expression = ReplaceWildcard(expression);