Skip to content

Commit 214e13c

Browse files
committed
Automatically fix missing slash in front of error page locations.
1 parent 428d7eb commit 214e13c

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
# Version 3.8.6 (2019-07-??)
1+
# Version 3.8.6 (2019-07-30)
22

33
* [new] Introduce the `diag` tool to manually write a diagnostic report to standard output or in a file.
4+
* [new] Enable configuration of Undertow error pages for specific HTTP codes or exceptions as well as a default error page (`web.server.errorPages` config).
45

56
# Version 3.8.5 (2019-03-22)
67

web/undertow/src/main/java/org/seedstack/seed/undertow/internal/DeploymentManagerFactory.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,16 @@ private DeploymentInfo configureDeploymentInfo() {
9090
private Collection<ErrorPage> buildUndertowErrorPages(List<WebConfig.ServerConfig.ErrorPage> errorPages) {
9191
List<ErrorPage> undertowErrorPages = new ArrayList<>();
9292
for (WebConfig.ServerConfig.ErrorPage errorPage : errorPages) {
93+
String location = errorPage.getLocation();
94+
if (!location.startsWith("/")) {
95+
location = "/" + location;
96+
}
9397
if (errorPage.getExceptionType() != null) {
94-
undertowErrorPages.add(new ErrorPage(errorPage.getLocation(), errorPage.getExceptionType()));
98+
undertowErrorPages.add(new ErrorPage(location, errorPage.getExceptionType()));
9599
} else if (errorPage.getErrorCode() != null) {
96-
undertowErrorPages.add(new ErrorPage(errorPage.getLocation(), errorPage.getErrorCode()));
100+
undertowErrorPages.add(new ErrorPage(location, errorPage.getErrorCode()));
97101
} else {
98-
undertowErrorPages.add(new ErrorPage(errorPage.getLocation()));
102+
undertowErrorPages.add(new ErrorPage(location));
99103
}
100104
}
101105
return undertowErrorPages;

web/undertow/src/test/resources/application.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ web:
1616
https<https>: true
1717
welcomeFiles<welcome>: [ 'welcome1.html', 'welcome2.html' ]
1818
errorPages<errorPages>:
19-
- location: /errors/404.html
19+
- location: errors/404.html
2020
errorCode: 404
2121
- location: /errors/415.html
2222
errorCode: 415

0 commit comments

Comments
 (0)