Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/processCss.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ var parserPlugin = postcss.plugin("css-loader-parser", function(options) {

module.exports = function processCss(inputSource, inputMap, options, callback) {
var query = options.query;
var root = query.root;
var root = query.root && query.root.length > 0 ? query.root.replace(/\/$/, "") : query.root;
var context = query.context;
var localIdentName = query.localIdentName || "[hash:base64]";
var localIdentRegExp = query.localIdentRegExp;
Expand Down
9 changes: 9 additions & 0 deletions test/urlTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@ describe("url", function() {
test("background img absolute with root", ".class { background: green url(/img.png) xyz }", [
[1, ".class { background: green url({./img.png}) xyz }", ""]
], "?root=.");
test("background img absolute with root", ".class { background: green url(/img.png) xyz }", [
[1, ".class { background: green url({./img.png}) xyz }", ""]
], "?root=./");
test("root with absolute url", ".class { background: green url(/img.png) xyz }", [
[1, ".class { background: green url(http://some.cdn.com/img.png) xyz }", ""]
], "?root=http://some.cdn.com");
test("root with absolute url with trailing slash", ".class { background: green url(/img.png) xyz }", [
[1, ".class { background: green url(http://some.cdn.com/img.png) xyz }", ""]
], "?root=http://some.cdn.com/");
test("background img external",
".class { background: green url(data:image/png;base64,AAA) url(http://example.com/image.jpg) url(//example.com/image.png) xyz }", [
[1, ".class { background: green url(data:image/png;base64,AAA) url(http://example.com/image.jpg) url(//example.com/image.png) xyz }", ""]
Expand Down