Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
d0c8f801
Commit
d0c8f801
authored
Jun 06, 2017
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '1.5.x'
parents
cdebfcde
ad629055
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
2 deletions
+27
-2
ResourceProperties.java
...gframework/boot/autoconfigure/web/ResourceProperties.java
+10
-1
ResourcePropertiesTests.java
...ework/boot/autoconfigure/web/ResourcePropertiesTests.java
+17
-1
No files found.
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ResourceProperties.java
View file @
d0c8f801
...
...
@@ -85,7 +85,16 @@ public class ResourceProperties implements ResourceLoaderAware {
}
public
void
setStaticLocations
(
String
[]
staticLocations
)
{
this
.
staticLocations
=
staticLocations
;
this
.
staticLocations
=
appendSlashIfNecessary
(
staticLocations
);
}
private
String
[]
appendSlashIfNecessary
(
String
[]
staticLocations
)
{
String
[]
normalized
=
new
String
[
staticLocations
.
length
];
for
(
int
i
=
0
;
i
<
staticLocations
.
length
;
i
++)
{
String
location
=
staticLocations
[
i
];
normalized
[
i
]
=
location
.
endsWith
(
"/"
)
?
location
:
location
+
"/"
;
}
return
normalized
;
}
public
Resource
getWelcomePage
()
{
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/ResourcePropertiesTests.java
View file @
d0c8f801
/*
* Copyright 2012-201
6
the original author or authors.
* Copyright 2012-201
7
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.
...
...
@@ -18,7 +18,10 @@ package org.springframework.boot.autoconfigure.web;
import
org.junit.Test
;
import
org.springframework.boot.testutil.Matched
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
static
org
.
hamcrest
.
CoreMatchers
.
endsWith
;
/**
* Tests for {@link ResourceProperties}.
...
...
@@ -52,4 +55,17 @@ public class ResourcePropertiesTests {
assertThat
(
this
.
properties
.
getChain
().
getEnabled
()).
isFalse
();
}
@Test
public
void
defaultStaticLocationsAllEndWithTrailingSlash
()
{
assertThat
(
this
.
properties
.
getStaticLocations
()).
are
(
Matched
.
by
(
endsWith
(
"/"
)));
}
@Test
public
void
customStaticLocationsAreNormalizedToEndWithTrailingSlash
()
{
this
.
properties
.
setStaticLocations
(
new
String
[]
{
"/foo"
,
"/bar"
,
"/baz/"
});
assertThat
(
this
.
properties
.
getStaticLocations
()).
containsExactly
(
"/foo/"
,
"/bar/"
,
"/baz/"
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment