Fixed #432 - adds URLs normalization.
authorJakub Pawlowicz <contact@jakubpawlowicz.com>
Wed, 21 Dec 2016 11:05:46 +0000 (12:05 +0100)
committerJakub Pawlowicz <contact@jakubpawlowicz.com>
Wed, 21 Dec 2016 11:05:46 +0000 (12:05 +0100)
Why:

* So further merging or compacting can happen more effectively
  even when initial URL formatting is different.

History.md
lib/reader/rewrite-url.js
test/fixtures/issue-432-min.css [new file with mode: 0644]
test/fixtures/issue-432.css [new file with mode: 0644]

index 45769eb..2af7aed 100644 (file)
@@ -7,6 +7,7 @@
 * Replaces the old tokenizer with a new one which doesn't use any escaping.
 * Replaces the old `@import` inlining with one on top of the new tokenizer.
 * Simplifies URL rebasing with a single `rebaseTo` option in API or inferred from `--output` in CLI.
+* Fixed issue [#432](https://github.com/jakubpawlowicz/clean-css/issues/432) - adds URLs normalization.
 * Fixed issue [#657](https://github.com/jakubpawlowicz/clean-css/issues/657) - adds property name validation.
 * Fixed issue [#686](https://github.com/jakubpawlowicz/clean-css/issues/686) - adds rounding precision for all units.
 * Fixed issue [#756](https://github.com/jakubpawlowicz/clean-css/issues/756) - adds disabling font-weight optimizations.
index 4fefbaf..29b09f7 100644 (file)
@@ -103,7 +103,8 @@ function rewriteUrl(originalUrl, rebaseConfig, pathOnly) {
 
   var unquotedUrl = strippedUrl
     .replace(QUOTE_PREFIX_PATTERN, '')
-    .replace(QUOTE_SUFFIX_PATTERN, '');
+    .replace(QUOTE_SUFFIX_PATTERN, '')
+    .trim();
 
   var quote = strippedUrl[0] == SINGLE_QUOTE || strippedUrl[0] == DOUBLE_QUOTE ?
     strippedUrl[0] :
diff --git a/test/fixtures/issue-432-min.css b/test/fixtures/issue-432-min.css
new file mode 100644 (file)
index 0000000..8f24964
--- /dev/null
@@ -0,0 +1 @@
+.c,.c-10,.c-11,.c-12,.c-2,.c-3,.c-4,.c-5,.c-6,.c-7,.c-8,.c-9{background-image:url(test/fixtures/images/image.png)}
diff --git a/test/fixtures/issue-432.css b/test/fixtures/issue-432.css
new file mode 100644 (file)
index 0000000..316a9a8
--- /dev/null
@@ -0,0 +1,77 @@
+/* Assets with non-stylistic syntax */
+
+.c {
+
+    background-image:url('images/image.png');
+
+}
+
+.c-2 {
+
+    background-image:    url('images/image.png');
+
+}
+
+.c-3 {
+
+    background-image:
+    url('images/image.png');
+
+}
+
+.c-4 {
+
+    background-image: url(    'images/image.png');
+
+}
+
+.c-5 {
+
+    background-image: url(
+'images/image.png');
+
+}
+
+.c-6 {
+
+    background-image: url('    images/image.png');
+
+}
+
+.c-7 {
+
+    background-image: url('images/image.png    ');
+
+}
+
+.c-8 {
+
+    background-image: url('images/image.png'    );
+
+}
+
+.c-9 {
+
+    background-image: url('images/image.png'
+);
+
+}
+
+.c-10 {
+
+    background-image: url('images/image.png')    ;
+
+}
+
+.c-11 {
+
+    background-image: url('images/image.png')
+;
+
+}
+
+.c-12 {
+
+    background-image: URL('images/image.png');
+
+}