Skip to content

Commit

Permalink
fix: wrong relative path, ref: #11
Browse files Browse the repository at this point in the history
  • Loading branch information
sparanoid committed Jan 20, 2017
1 parent 9037ad7 commit 768aff1
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions tasks/assets_inline.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ module.exports = function(grunt) {
if (!src.match(/.svg$/i)) { return; }
if (url.parse(src).protocol) { return; }

var filePath = (src.substr(0,1) === '/') ? path.resolve(options.assetsDir, src.substr(1)) : path.join(path.dirname(filePair.src), src);
var filePath = (src.substr(0,1) === '/') ? path.resolve(options.assetsDir, src.substr(1)) : path.join(path.dirname(filePair.src.toString()), src);
grunt.log.writeln((' inline: ').cyan + filePath);

if (options.inlineSvgBase64) {
Expand Down Expand Up @@ -182,7 +182,7 @@ module.exports = function(grunt) {
if(url.parse(src).protocol) { return; }
src = src.replace(/\?.+$/, '');

var filePath = (src.substr(0,1) === '/') ? path.resolve(options.assetsDir, src.substr(1)) : path.join(path.dirname(filePair.src), src);
var filePath = (src.substr(0,1) === '/') ? path.resolve(options.assetsDir, src.substr(1)) : path.join(path.dirname(filePair.src.toString()), src);

if (src.match(/.svg$/i)) {
if (options.inlineSvgBase64) {
Expand Down Expand Up @@ -217,7 +217,7 @@ module.exports = function(grunt) {
if (!src.match(/.svg$/i)) { return; }
if (url.parse(src).protocol) { return; }

var filePath = (src.substr(0,1) === "/") ? path.resolve(options.assetsDir, src.substr(1)) : path.join(path.dirname(filePair.src), src);
var filePath = (src.substr(0,1) === "/") ? path.resolve(options.assetsDir, src.substr(1)) : path.join(path.dirname(filePair.src.toString()), src);
grunt.log.writeln((' svg: ').cyan + filePath);

if (options.inlineSvgBase64) {
Expand All @@ -240,7 +240,7 @@ module.exports = function(grunt) {
if (src.match(/.svg$/i)) { return; }
if (url.parse(src).protocol) { return; }

var filePath = (src.substr(0,1) === "/") ? path.resolve(options.assetsDir, src.substr(1)) : path.join(path.dirname(filePair.src), src);
var filePath = (src.substr(0,1) === "/") ? path.resolve(options.assetsDir, src.substr(1)) : path.join(path.dirname(filePair.src.toString()), src);
grunt.log.writeln((' image: ').cyan + filePath);

$(this).attr('src', 'data:image/' + src.substr(src.lastIndexOf('.')+1) + ';base64,' + new Buffer(grunt.file.read(filePath, { encoding: null })).toString('base64'));
Expand Down

0 comments on commit 768aff1

Please sign in to comment.