Fixes #192 - many `@import`s inside a comment.
authorGoalSmashers <jakub@goalsmashers.com>
Wed, 18 Dec 2013 21:49:48 +0000 (22:49 +0100)
committerGoalSmashers <jakub@goalsmashers.com>
Wed, 18 Dec 2013 22:16:12 +0000 (23:16 +0100)
* Broken comments scanner when more than one import inside a comment.

History.md
lib/imports/inliner.js
test/data/issue-192-min.css [new file with mode: 0644]
test/data/issue-192.css [new file with mode: 0644]

index 2654a62..fd9a84e 100644 (file)
@@ -13,6 +13,7 @@
 ==================
 
 * Fixed issue [#191](https://github.com/GoalSmashers/clean-css/issues/191) - leading numbers in font/animation names.
+* Fixed issue [#192](https://github.com/GoalSmashers/clean-css/issues/192) - many `@import`s inside a comment.
 
 [2.0.2 / 2013-11-18](https://github.com/GoalSmashers/clean-css/compare/v2.0.1...v2.0.2)
 ==================
index acd5d71..e1e359a 100644 (file)
@@ -56,6 +56,10 @@ module.exports = function Inliner(context) {
       if (noComments)
         return false;
 
+      // idx can be still within last matched comment (many @import statements inside one comment)
+      if (idx < lastEndIndex)
+        return true;
+
       comment = data.match(commentRegex);
 
       if (!comment) {
diff --git a/test/data/issue-192-min.css b/test/data/issue-192-min.css
new file mode 100644 (file)
index 0000000..14033f0
--- /dev/null
@@ -0,0 +1 @@
+.vrac{overflow:hidden;position:relative}
diff --git a/test/data/issue-192.css b/test/data/issue-192.css
new file mode 100644 (file)
index 0000000..7584539
--- /dev/null
@@ -0,0 +1,8 @@
+/*
+@import url(//fonts.googleapis.com/css?family=PT+Sans+Caption:400italic,400,700italic,700);
+@import url(//fonts.googleapis.com/css?family=Droid+Sans:400,700);
+*/
+.vrac {
+  overflow: hidden;
+  position: relative
+}