reworkcss / rework-plugin-url

url() plugin for rework, formerly included in core

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

necolas opened this issue · comments

Move from: reworkcss/rework#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:

  • url( "path/to/some/image.png" )
  • url( path/to/some/image.png )
  • url( 'path/to/some/image.png')
  • url('path/to/some/image.png' )

and so on.