Combined, empty RequestMapping matches both "" and "/"

Closes gh-29625
This commit is contained in:
rstoyanchev
2023-01-09 16:56:29 +00:00
parent 46875c91ce
commit 312db36849
8 changed files with 40 additions and 35 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -59,8 +59,8 @@ public class PathPatternsRequestConditionTests {
PathPatternsRequestCondition c2 = createCondition();
PathPatternsRequestCondition c3 = c1.combine(c2);
assertThat(c3).isSameAs(c1);
assertThat(c1.getPatternValues()).isSameAs(c2.getPatternValues()).containsExactly("");
assertThat(c3.getPatternValues()).containsExactly("", "/");
}
@Test

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -58,8 +58,8 @@ class PatternsRequestConditionTests {
PatternsRequestCondition c2 = new PatternsRequestCondition();
PatternsRequestCondition c3 = c1.combine(c2);
assertThat(c3).isSameAs(c1);
assertThat(c1.getPatterns()).isSameAs(c2.getPatterns()).containsExactly("");
assertThat(c3.getPatterns()).containsExactly("", "/");
}
@Test

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -77,7 +77,7 @@ class RequestMappingInfoTests {
assertThat(info.getCustomCondition()).isSameAs(anotherInfo.getCustomCondition());
RequestMappingInfo result = info.combine(anotherInfo);
assertThat(info.getActivePatternsCondition()).isSameAs(result.getActivePatternsCondition());
assertThat(result.getPatternValues()).containsExactly("", "/");
assertThat(info.getMethodsCondition()).isSameAs(result.getMethodsCondition());
assertThat(info.getParamsCondition()).isSameAs(result.getParamsCondition());
assertThat(info.getHeadersCondition()).isSameAs(result.getHeadersCondition());