reworkcss / rework-plugin-url

url() plugin for rework, formerly included in core
MIT License
25 stars 7 forks source link

url plugin does not work properly when there is a space after opening bracket or before closing bracket #1

Closed necolas closed 10 years ago

necolas commented 10 years ago

Move from: https://github.com/reworkcss/rework/issues/154

According to CSS 2.1 specification, URI value can contain space after url( or before ). url plugin processes incorrectly such values. Consider the following code:

var rework = require("rework");
var css = rework("body { \n background-image: url( 'path/to/some/image.png' );\n }")
            .use(rework.url(function(url){
                return url;
            }))
            .toString();
console.log(css);

Wrong CSS code will be printed:

body {
  background-image: url(" 'path/to/some/image.png' ");
}

The following URLs are also processed incorrectly:

and so on.