Skip to content

Commit 8553c04

Browse files
committed
Bumping versions
1 parent 6377e31 commit 8553c04

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

spring-cloud-gateway-server-mvc/src/main/java/org/springframework/cloud/gateway/server/mvc/filter/BeforeFilterFunctions.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,11 @@ public static Function<ServerRequest, ServerRequest> rewritePath(String regexp,
332332
String path = request.uri().getPath();
333333
String newPath = pattern.matcher(path).replaceAll(normalizedReplacement);
334334

335-
URI rewrittenUri = UriComponentsBuilder.fromUri(request.uri()).replacePath(newPath).encode().build().toUri();
335+
URI rewrittenUri = UriComponentsBuilder.fromUri(request.uri())
336+
.replacePath(newPath)
337+
.encode()
338+
.build()
339+
.toUri();
336340

337341
ServerRequest modified = ServerRequest.from(request).uri(rewrittenUri).build();
338342

spring-cloud-gateway-server-mvc/src/test/java/org/springframework/cloud/gateway/server/mvc/filter/BeforeFilterFunctionsTests.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,7 @@ void stripPrefixWithEncodedParameters() {
186186

187187
@Test
188188
void rewritePath() {
189-
MockHttpServletRequest servletRequest = MockMvcRequestBuilders.get("http://localhost/get")
190-
.buildRequest(null);
189+
MockHttpServletRequest servletRequest = MockMvcRequestBuilders.get("http://localhost/get").buildRequest(null);
191190

192191
ServerRequest request = ServerRequest.create(servletRequest, Collections.emptyList());
193192

@@ -199,7 +198,7 @@ void rewritePath() {
199198
@Test
200199
void rewritePathWithSpace() {
201200
MockHttpServletRequest servletRequest = MockMvcRequestBuilders.get("http://localhost/get/path/with spaces")
202-
.buildRequest(null);
201+
.buildRequest(null);
203202

204203
ServerRequest request = ServerRequest.create(servletRequest, Collections.emptyList());
205204

@@ -211,7 +210,7 @@ void rewritePathWithSpace() {
211210
@Test
212211
void rewritePathWithEnDash() {
213212
MockHttpServletRequest servletRequest = MockMvcRequestBuilders.get("http://localhost/get/path/with–en–dashes")
214-
.buildRequest(null);
213+
.buildRequest(null);
215214

216215
ServerRequest request = ServerRequest.create(servletRequest, Collections.emptyList());
217216

@@ -222,14 +221,16 @@ void rewritePathWithEnDash() {
222221

223222
@Test
224223
void rewritePathWithEnDashAndSpace() {
225-
MockHttpServletRequest servletRequest = MockMvcRequestBuilders.get("http://localhost/get/path/with–en–dashes and spaces")
226-
.buildRequest(null);
224+
MockHttpServletRequest servletRequest = MockMvcRequestBuilders
225+
.get("http://localhost/get/path/with–en–dashes and spaces")
226+
.buildRequest(null);
227227

228228
ServerRequest request = ServerRequest.create(servletRequest, Collections.emptyList());
229229

230230
ServerRequest modified = BeforeFilterFunctions.rewritePath("get", "modified").apply(request);
231231

232-
assertThat(modified.uri().getRawPath()).isEqualTo("/modified/path/with%E2%80%93en%E2%80%93dashes%20and%20spaces");
232+
assertThat(modified.uri().getRawPath())
233+
.isEqualTo("/modified/path/with%E2%80%93en%E2%80%93dashes%20and%20spaces");
233234
}
234235

235236
}

0 commit comments

Comments
 (0)