mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-08-29 03:06:45 +08:00
Merge branch '2.2.x'
Closes gh-21560
This commit is contained in:
commit
1d2d76b051
@ -110,6 +110,9 @@ public final class WebFluxTags {
|
||||
if (ignoreTrailingSlash && patternString.length() > 1) {
|
||||
patternString = TRAILING_SLASH_PATTERN.matcher(patternString).replaceAll("");
|
||||
}
|
||||
if (patternString.isEmpty()) {
|
||||
return URI_ROOT;
|
||||
}
|
||||
return Tag.of("uri", patternString);
|
||||
}
|
||||
HttpStatus status = exchange.getResponse().getStatusCode();
|
||||
|
@ -115,6 +115,9 @@ public final class WebMvcTags {
|
||||
if (ignoreTrailingSlash && pattern.length() > 1) {
|
||||
pattern = TRAILING_SLASH_PATTERN.matcher(pattern).replaceAll("");
|
||||
}
|
||||
if (pattern.isEmpty()) {
|
||||
return URI_ROOT;
|
||||
}
|
||||
return Tag.of("uri", pattern);
|
||||
}
|
||||
if (response != null) {
|
||||
|
@ -58,6 +58,14 @@ class WebMvcTagsTests {
|
||||
assertThat(tag.getValue()).isEqualTo("/spring/");
|
||||
}
|
||||
|
||||
@Test
|
||||
void uriTagValueIsRootWhenBestMatchingPatternIsEmpty() {
|
||||
this.request.setAttribute(HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE, "");
|
||||
this.response.setStatus(301);
|
||||
Tag tag = WebMvcTags.uri(this.request, this.response);
|
||||
assertThat(tag.getValue()).isEqualTo("root");
|
||||
}
|
||||
|
||||
@Test
|
||||
void uriTagValueWithBestMatchingPatternAndIgnoreTrailingSlashRemoveTrailingSlash() {
|
||||
this.request.setAttribute(HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE, "/spring/");
|
||||
|
@ -61,6 +61,14 @@ class WebFluxTagsTests {
|
||||
assertThat(tag.getValue()).isEqualTo("/spring/");
|
||||
}
|
||||
|
||||
@Test
|
||||
void uriTagValueIsRootWhenBestMatchingPatternIsEmpty() {
|
||||
this.exchange.getAttributes().put(HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE, this.parser.parse(""));
|
||||
this.exchange.getResponse().setStatusCode(HttpStatus.MOVED_PERMANENTLY);
|
||||
Tag tag = WebFluxTags.uri(this.exchange);
|
||||
assertThat(tag.getValue()).isEqualTo("root");
|
||||
}
|
||||
|
||||
@Test
|
||||
void uriTagValueWithBestMatchingPatternAndIgnoreTrailingSlashRemoveTrailingSlash() {
|
||||
this.exchange.getAttributes().put(HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE,
|
||||
|
Loading…
Reference in New Issue
Block a user