Skip to content

Commit b382bb6

Browse files
committed
Bumping versions
1 parent b68c391 commit b382bb6

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
@@ -184,8 +184,7 @@ void stripPrefixWithEncodedParameters() {
184184

185185
@Test
186186
void rewritePath() {
187-
MockHttpServletRequest servletRequest = MockMvcRequestBuilders.get("http://localhost/get")
188-
.buildRequest(null);
187+
MockHttpServletRequest servletRequest = MockMvcRequestBuilders.get("http://localhost/get").buildRequest(null);
189188

190189
ServerRequest request = ServerRequest.create(servletRequest, Collections.emptyList());
191190

@@ -197,7 +196,7 @@ void rewritePath() {
197196
@Test
198197
void rewritePathWithSpace() {
199198
MockHttpServletRequest servletRequest = MockMvcRequestBuilders.get("http://localhost/get/path/with spaces")
200-
.buildRequest(null);
199+
.buildRequest(null);
201200

202201
ServerRequest request = ServerRequest.create(servletRequest, Collections.emptyList());
203202

@@ -209,7 +208,7 @@ void rewritePathWithSpace() {
209208
@Test
210209
void rewritePathWithEnDash() {
211210
MockHttpServletRequest servletRequest = MockMvcRequestBuilders.get("http://localhost/get/path/with–en–dashes")
212-
.buildRequest(null);
211+
.buildRequest(null);
213212

214213
ServerRequest request = ServerRequest.create(servletRequest, Collections.emptyList());
215214

@@ -220,14 +219,16 @@ void rewritePathWithEnDash() {
220219

221220
@Test
222221
void rewritePathWithEnDashAndSpace() {
223-
MockHttpServletRequest servletRequest = MockMvcRequestBuilders.get("http://localhost/get/path/with–en–dashes and spaces")
224-
.buildRequest(null);
222+
MockHttpServletRequest servletRequest = MockMvcRequestBuilders
223+
.get("http://localhost/get/path/with–en–dashes and spaces")
224+
.buildRequest(null);
225225

226226
ServerRequest request = ServerRequest.create(servletRequest, Collections.emptyList());
227227

228228
ServerRequest modified = BeforeFilterFunctions.rewritePath("get", "modified").apply(request);
229229

230-
assertThat(modified.uri().getRawPath()).isEqualTo("/modified/path/with%E2%80%93en%E2%80%93dashes%20and%20spaces");
230+
assertThat(modified.uri().getRawPath())
231+
.isEqualTo("/modified/path/with%E2%80%93en%E2%80%93dashes%20and%20spaces");
231232
}
232233

233234
}

0 commit comments

Comments
 (0)