|
28 | 28 |
|
29 | 29 | /**
|
30 | 30 | * @author raccoonback
|
| 31 | + * @author Jens Mallien |
31 | 32 | */
|
32 | 33 | class BeforeFilterFunctionsTests {
|
33 | 34 |
|
@@ -181,4 +182,52 @@ void stripPrefixWithEncodedParameters() {
|
181 | 182 | assertThat(result.uri().toString()).hasToString("http://localhost/depth3?baz%5B%5D=qux%5B%5D");
|
182 | 183 | }
|
183 | 184 |
|
| 185 | + @Test |
| 186 | + void rewritePath() { |
| 187 | + MockHttpServletRequest servletRequest = MockMvcRequestBuilders.get("http://localhost/get") |
| 188 | + .buildRequest(null); |
| 189 | + |
| 190 | + ServerRequest request = ServerRequest.create(servletRequest, Collections.emptyList()); |
| 191 | + |
| 192 | + ServerRequest modified = BeforeFilterFunctions.rewritePath("get", "modified").apply(request); |
| 193 | + |
| 194 | + assertThat(modified.uri().getRawPath()).isEqualTo("/modified"); |
| 195 | + } |
| 196 | + |
| 197 | + @Test |
| 198 | + void rewritePathWithSpace() { |
| 199 | + MockHttpServletRequest servletRequest = MockMvcRequestBuilders.get("http://localhost/get/path/with spaces") |
| 200 | + .buildRequest(null); |
| 201 | + |
| 202 | + ServerRequest request = ServerRequest.create(servletRequest, Collections.emptyList()); |
| 203 | + |
| 204 | + ServerRequest modified = BeforeFilterFunctions.rewritePath("get", "modified").apply(request); |
| 205 | + |
| 206 | + assertThat(modified.uri().getRawPath()).isEqualTo("/modified/path/with%20spaces"); |
| 207 | + } |
| 208 | + |
| 209 | + @Test |
| 210 | + void rewritePathWithEnDash() { |
| 211 | + MockHttpServletRequest servletRequest = MockMvcRequestBuilders.get("http://localhost/get/path/with–en–dashes") |
| 212 | + .buildRequest(null); |
| 213 | + |
| 214 | + ServerRequest request = ServerRequest.create(servletRequest, Collections.emptyList()); |
| 215 | + |
| 216 | + ServerRequest modified = BeforeFilterFunctions.rewritePath("get", "modified").apply(request); |
| 217 | + |
| 218 | + assertThat(modified.uri().getRawPath()).isEqualTo("/modified/path/with%E2%80%93en%E2%80%93dashes"); |
| 219 | + } |
| 220 | + |
| 221 | + @Test |
| 222 | + void rewritePathWithEnDashAndSpace() { |
| 223 | + MockHttpServletRequest servletRequest = MockMvcRequestBuilders.get("http://localhost/get/path/with–en–dashes and spaces") |
| 224 | + .buildRequest(null); |
| 225 | + |
| 226 | + ServerRequest request = ServerRequest.create(servletRequest, Collections.emptyList()); |
| 227 | + |
| 228 | + ServerRequest modified = BeforeFilterFunctions.rewritePath("get", "modified").apply(request); |
| 229 | + |
| 230 | + assertThat(modified.uri().getRawPath()).isEqualTo("/modified/path/with%E2%80%93en%E2%80%93dashes%20and%20spaces"); |
| 231 | + } |
| 232 | + |
184 | 233 | }
|
0 commit comments