Permalink
Browse files

fix: wrong relative path, ref: #11

  • Loading branch information...
sparanoid committed Jan 20, 2017
1 parent 9037ad7 commit 768aff1dba810d14757eff71193ba1658fbcc55c
Showing with 4 additions and 4 deletions.
  1. +4 −4 tasks/assets_inline.js
@@ -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) {
@@ -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) {
@@ -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) {
@@ -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'));

0 comments on commit 768aff1

Please sign in to comment.