Skip to content

Commit 61ae92c

Browse files
committed
fixed multi url bug
1 parent 0a108a3 commit 61ae92c

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
Author Tobias Koppers @sokra
44
*/
55
var csso = require("csso");
6-
var uriRegExp = /%CSSURL\[%(.*)%\]CSSURL%/g;
76
module.exports = function(content) {
87
var isRequireUrl = !this || !this.options || !this.options.css ||
98
typeof this.options.css.requireUrl === "string";
@@ -32,8 +31,9 @@ module.exports = function(content) {
3231

3332
var css = JSON.stringify(csso.translate(tree));
3433
if(isRequireUrl) {
35-
css = css.replace(uriRegExp, function(match) {
36-
match = uriRegExp.exec(match);
34+
var uriRegExp = /%CSSURL\[%(.*?)%\]CSSURL%/g;
35+
css = css.replace(uriRegExp, function(str) {
36+
match = /^%CSSURL\[%(.*?)%\]CSSURL%$/.exec(str);
3737
var url = JSON.parse("\"" + match[1] + "\"");
3838
return "\"+require(" + JSON.stringify(requireUrl + urlToRequire(url)) + ")+\"";
3939
});

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "css-loader",
3-
"version": "0.2.1",
3+
"version": "0.2.2",
44
"author": "Tobias Koppers @sokra",
55
"description": "css loader module for webpack",
66
"dependencies": {

test/url_test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,6 @@ vows.describe("url").addBatch({
3939
test(".class { background: green url( \"img.png\" ) xyz }",
4040
["\".class { background: green url( \"+require(\"file/auto!./img.png\")+\" ) xyz }\""]),
4141
"background img 2":
42-
test(".class { background: green url(~img/png ) xyz }",
43-
["\".class { background: green url(\"+require(\"file/auto!img/png\")+\" ) xyz }\""])
42+
test(".class { background: green url(~img/png ) url(aaa) xyz }",
43+
["\".class { background: green url(\"+require(\"file/auto!img/png\")+\" ) url(\"+require(\"file/auto!./aaa\")+\") xyz }\""])
4444
}).export(module);

0 commit comments

Comments
 (0)