Skip to content

Commit

Permalink
fix issue #7
Browse files Browse the repository at this point in the history
  • Loading branch information
JacksonTian committed Oct 7, 2016
1 parent aaa28a1 commit 812b3f9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,10 @@ exports.processUrl = function (basedir, text, fileCache, to) {
return text.replace(reg, function (match, $1, $2, $3) {
var target = $2;

// ignore uri
if (target.startsWith('http://') || target.startsWith('https://')) {
// ignore uri & data-uri
if (target.startsWith('http://') ||
target.startsWith('https://') ||
target.startsWith('data:')) {
return $1 + target + $3;
}

Expand Down
6 changes: 6 additions & 0 deletions test/builder.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,12 @@ describe('builder', function () {
output.should.be.equal(`background-image: url('http://domain.com/assets/images/test.jpg');`);
});

it('processUrl with data:uri should ok', function () {
var input = `background-image: url('data:,Hello%2C%20World!');`;
var output = builder.processUrl(__dirname, input, {});
output.should.be.equal(`background-image: url('data:,Hello%2C%20World!');`);
});

it('processUrl with (..) should ok', function () {
var input = `background-image: url('../images/test.jpg');`;
var output = builder.processUrl(__dirname, input, {}, '/assets/styles/main.css');
Expand Down

0 comments on commit 812b3f9

Please sign in to comment.