Skip to content

Commit 96d9a8e

Browse files
committed
fixes #8
1 parent 49d0486 commit 96d9a8e

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

index.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,13 @@ module.exports = function(content) {
4040
if(/^data:|^(https?:)?\/\//.test(match[1])) return match[1];
4141
var idx = match[1].indexOf("?");
4242
if(idx < 0) idx = match[1].indexOf("#");
43-
if(idx >= 0) {
43+
if(idx > 0) {
4444
// in cases like url('webfont.eot?#iefix')
4545
var url = JSON.parse("\"" + match[1].substr(0, idx) + "\"");
4646
return "\"+require(" + JSON.stringify(urlToRequire(url)) + ")+\"" + match[1].substr(idx);
47+
} else if(idx === 0) {
48+
// only hash
49+
return match[1];
4750
}
4851
var url = JSON.parse("\"" + match[1] + "\"");
4952
return "\"+require(" + JSON.stringify(urlToRequire(url)) + ")+\"";

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "css-loader",
3-
"version": "0.6.7",
3+
"version": "0.6.8",
44
"author": "Tobias Koppers @sokra",
55
"description": "css loader module for webpack",
66
"dependencies": {

test/urlTest.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,12 @@ describe("url", function() {
5858
["\".class { background: green url( \"+require(\"./img.png\")+\" ) xyz }\""]);
5959
test("background img 2", ".class { background: green url(~img/png ) url(aaa) xyz }",
6060
["\".class { background: green url(\"+require(\"img/png\")+\" ) url(\"+require(\"./aaa\")+\") xyz }\""]);
61-
test("background img external",
61+
test("background img external",
6262
".class { background: green url(data:image/png;base64,AAA) url(http://example.com/image.jpg) url(//example.com/image.png) xyz }",
6363
["\".class { background: green url(data:image/png;base64,AAA) url(http://example.com/image.jpg) url(//example.com/image.png) xyz }\""]);
64+
test("filter hash",
65+
".highlight { filter: url(#highlight); }",
66+
["\".highlight { filter: url(#highlight); }\""]);
6467
test("font face", "@font-face { src: url(regular.woff) format('woff'), url(~truetype/regular.ttf) format('truetype') }",
6568
["\"@font-face { src: url(\"+require(\"./regular.woff\")+\") format('woff'), url(\"+require(\"truetype/regular.ttf\")+\") format('truetype') }\""]);
6669
testMinimize("minimized simple", ".class { a: b c d; }",

0 commit comments

Comments
 (0)