var inlinedFile = function() {
var importedFile = data
- .substring(data.indexOf('(', nextStart) + 1, nextEnd)
+ .substring(data.indexOf(' ', nextStart) + 1, nextEnd)
+ .replace(/^url\(/, '')
+ .replace(/\)$/, '')
.replace(/['"]/g, '');
if (/^(http|https):\/\//.test(importedFile))
};
for (; nextEnd < data.length; ) {
- nextStart = data.indexOf('@import url(', cursor);
+ nextStart = data.indexOf('@import', cursor);
if (nextStart == -1)
break;
- nextEnd = data.indexOf(')', nextStart);
+ nextEnd = data.indexOf(';', nextStart);
if (nextEnd == -1)
break;
tempData.push(data.substring(cursor, nextStart));
tempData.push(inlinedFile());
- cursor = nextEnd + 2;
+ cursor = nextEnd + 1;
}
return tempData.length > 0 ?
"@import url('test/data/partials/one.css');",
".one{color:red}"
],
+ 'of a real file with double-quoted path': [
+ '@import url("test/data/partials/one.css");',
+ ".one{color:red}"
+ ],
+ 'of a real file with bare path': [
+ "@import test/data/partials/one.css;",
+ ".one{color:red}"
+ ],
+ 'of a real file with bare quoted path': [
+ "@import 'test/data/partials/one.css';",
+ ".one{color:red}"
+ ],
+ 'of a real file with bare double-quoted path': [
+ '@import "test/data/partials/one.css";',
+ ".one{color:red}"
+ ],
'of more files': [
"@import url(test/data/partials/one.css);\n\na{}\n\n@import url(test/data/partials/extra/three.css);",
".one{color:red}a{}.three{color:#0f0}"