提交 4af5229a 编写于 作者: S Sam Brannen

Verify that CssLinkResourceTransformer handles empty url() links

This commit introduces a test that verifies that
CssLinkResourceTransformer properly handles empty url() functions in
CSS files.

See gh-22602
上级 ae2ecf05
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2019 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.
......@@ -32,10 +32,10 @@ import org.springframework.util.StringUtils;
import static org.junit.Assert.*;
/**
* Unit tests for
* {@link org.springframework.web.servlet.resource.CssLinkResourceTransformer}.
* Unit tests for {@link CssLinkResourceTransformer}.
*
* @author Rossen Stoyanchev
* @author Sam Brannen
* @since 4.1
*/
public class CssLinkResourceTransformerTests {
......@@ -120,4 +120,23 @@ public class CssLinkResourceTransformerTests {
assertSame(expected, actual);
}
@Test // https://github.com/spring-projects/spring-framework/issues/22602
public void transformEmptyUrlFunction() throws Exception {
this.request = new MockHttpServletRequest("GET", "/static/empty_url_function.css");
Resource css = getResource("empty_url_function.css");
String expected =
".fooStyle {\n" +
"\tbackground: transparent url() no-repeat left top;\n" +
"}";
TransformedResource actual = (TransformedResource) this.transformerChain.transform(this.request, css);
String result = new String(actual.getByteArray(), "UTF-8");
result = StringUtils.deleteAny(result, "\r");
assertEquals(expected, result);
}
private Resource getResource(String filePath) {
return new ClassPathResource("test/" + filePath, getClass());
}
}
.fooStyle {
background: transparent url() no-repeat left top;
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册