|
1 | 1 | /*
|
2 |
| - * Copyright 2002-2014 the original author or authors. |
| 2 | + * Copyright 2002-2019 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
32 | 32 | import static org.junit.Assert.*;
|
33 | 33 |
|
34 | 34 | /**
|
35 |
| - * Unit tests for |
36 |
| - * {@link org.springframework.web.servlet.resource.CssLinkResourceTransformer}. |
| 35 | + * Unit tests for {@link CssLinkResourceTransformer}. |
37 | 36 | *
|
38 | 37 | * @author Rossen Stoyanchev
|
| 38 | + * @author Sam Brannen |
39 | 39 | * @since 4.1
|
40 | 40 | */
|
41 | 41 | public class CssLinkResourceTransformerTests {
|
@@ -120,4 +120,23 @@ public void transformWithNonCssResource() throws Exception {
|
120 | 120 | assertSame(expected, actual);
|
121 | 121 | }
|
122 | 122 |
|
| 123 | + @Test // https://github.com/spring-projects/spring-framework/issues/22602 |
| 124 | + public void transformEmptyUrlFunction() throws Exception { |
| 125 | + this.request = new MockHttpServletRequest("GET", "/static/empty_url_function.css"); |
| 126 | + Resource css = getResource("empty_url_function.css"); |
| 127 | + String expected = |
| 128 | + ".fooStyle {\n" + |
| 129 | + "\tbackground: transparent url() no-repeat left top;\n" + |
| 130 | + "}"; |
| 131 | + |
| 132 | + TransformedResource actual = (TransformedResource) this.transformerChain.transform(this.request, css); |
| 133 | + String result = new String(actual.getByteArray(), "UTF-8"); |
| 134 | + result = StringUtils.deleteAny(result, "\r"); |
| 135 | + assertEquals(expected, result); |
| 136 | + } |
| 137 | + |
| 138 | + private Resource getResource(String filePath) { |
| 139 | + return new ClassPathResource("test/" + filePath, getClass()); |
| 140 | + } |
| 141 | + |
123 | 142 | }
|
0 commit comments