diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/StaticResourceLocation.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/StaticResourceLocation.java index 19c1cd2200..1d6f62ae6b 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/StaticResourceLocation.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/StaticResourceLocation.java @@ -50,7 +50,7 @@ public enum StaticResourceLocation { /** * The {@code "favicon.ico"} resource. */ - FAVICON("/**/favicon.ico"); + FAVICON("/favicon.*", "/*/icon-*"); private final String[] patterns; diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/reactive/StaticResourceRequest.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/reactive/StaticResourceRequest.java index 9d6b71c122..a1609fa952 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/reactive/StaticResourceRequest.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/reactive/StaticResourceRequest.java @@ -128,8 +128,7 @@ public final class StaticResourceRequest { } private Stream getPatterns() { - return this.locations.stream().flatMap(StaticResourceLocation::getPatterns) - .map((pattern) -> pattern.replace("/**/", "/*/")); + return this.locations.stream().flatMap(StaticResourceLocation::getPatterns); } @Override diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/reactive/StaticResourceRequestTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/reactive/StaticResourceRequestTests.java index 7df939f947..556a1d94e6 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/reactive/StaticResourceRequestTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/reactive/StaticResourceRequestTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2020 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. @@ -54,7 +54,9 @@ class StaticResourceRequestTests { assertMatcher(matcher).matches("/js/file.js"); assertMatcher(matcher).matches("/images/file.css"); assertMatcher(matcher).matches("/webjars/file.css"); - assertMatcher(matcher).matches("/foo/favicon.ico"); + assertMatcher(matcher).matches("/favicon.ico"); + assertMatcher(matcher).matches("/favicon.png"); + assertMatcher(matcher).matches("/icons/icon-48x48.png"); assertMatcher(matcher).doesNotMatch("/bar"); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/servlet/StaticResourceRequestTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/servlet/StaticResourceRequestTests.java index 60335af7e0..26babb807d 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/servlet/StaticResourceRequestTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/servlet/StaticResourceRequestTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2020 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. @@ -48,7 +48,9 @@ class StaticResourceRequestTests { assertMatcher(matcher).matches("/js/file.js"); assertMatcher(matcher).matches("/images/file.css"); assertMatcher(matcher).matches("/webjars/file.css"); - assertMatcher(matcher).matches("/foo/favicon.ico"); + assertMatcher(matcher).matches("/favicon.ico"); + assertMatcher(matcher).matches("/favicon.png"); + assertMatcher(matcher).matches("/icons/icon-48x48.png"); assertMatcher(matcher).doesNotMatch("/bar"); } diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/spring-boot-features.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/spring-boot-features.adoc index 29dba35b35..c77e641a30 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/spring-boot-features.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/spring-boot-features.adoc @@ -2639,13 +2639,6 @@ If either is found, it is automatically used as the welcome page of the applicat -[[boot-features-spring-mvc-favicon]] -==== Custom Favicon -As with other static resources, Spring Boot looks for a `favicon.ico` in the configured static content locations. -If such a file is present, it is automatically used as the favicon of the application. - - - [[boot-features-spring-mvc-pathmatch]] ==== Path Matching and Content Negotiation Spring MVC can map incoming HTTP requests to handlers by looking at the request path and matching it to the mappings defined in your application (for example, `@GetMapping` annotations on Controller methods).