Skip to content

Commit

Permalink
fix: url with a trailing space is now handled correctly (#494)
Browse files Browse the repository at this point in the history
  • Loading branch information
evilebottnawi authored and michael-ciniawsky committed Apr 20, 2017
1 parent fbb0714 commit e1ec4f2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
2 changes: 2 additions & 0 deletions lib/processCss.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ module.exports = function processCss(inputSource, inputMap, options, callback) {
mode: options.mode,
rewriteUrl: function(global, url) {
if(parserOptions.url){
url = url.trim(" ");

if(!loaderUtils.isUrlRequest(url, root)) {
return url;
}
Expand Down
16 changes: 11 additions & 5 deletions test/urlTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,15 @@ describe("url", function() {
test("background img 3", ".class { background: green url( 'img.png' ) xyz }", [
[1, ".class { background: green url({./img.png}) xyz }", ""]
]);
test("background img contain space in name", ".class { background: green url( \"img img.png\" ) xyz }", [
[1, ".class { background: green url(\"{./img img.png}\") xyz }", ""]
]);
test("background 2 img contain space in name", ".class { background: green url( 'img img.png' ) xyz }", [
[1, ".class { background: green url('{./img img.png}') xyz }", ""]
test("background img 4", ".class { background: green url( img.png ) xyz }", [
[1, ".class { background: green url({./img.png}) xyz }", ""]
]);
test("background img contain space in name", ".class { background: green url( \"img img.png\" ) xyz }", [
[1, ".class { background: green url(\"{./img img.png}\") xyz }", ""]
]);
test("background 2 img contain space in name", ".class { background: green url( 'img img.png' ) xyz }", [
[1, ".class { background: green url('{./img img.png}') xyz }", ""]
]);
test("background img absolute", ".class { background: green url(/img.png) xyz }", [
[1, ".class { background: green url(/img.png) xyz }", ""]
]);
Expand Down Expand Up @@ -77,6 +80,9 @@ describe("url", function() {
test("background img 3 with url", ".class { background: green url( 'img.png' ) xyz }", [
[1, ".class { background: green url( 'img.png' ) xyz }", ""]
], "?-url");
test("background img 4 with url", ".class { background: green url( img.png ) xyz }", [
[1, ".class { background: green url( img.png ) xyz }", ""]
], "?-url");
test("background img with url contain space in name", ".class { background: green url( \"img img.png\" ) xyz }", [
[1, ".class { background: green url( \"img img.png\" ) xyz }", ""]
], "?-url");
Expand Down

0 comments on commit e1ec4f2

Please sign in to comment.