From 8d00e82236d2942295548bbeaa75a1282c5ec73d Mon Sep 17 00:00:00 2001 From: Noonan Media Date: Fri, 15 Jan 2016 16:41:36 +0000 Subject: [PATCH] Fix breakage in inline non Base64 SVG --- tasks/inline.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tasks/inline.js b/tasks/inline.js index 556077d..49ab33f 100644 --- a/tasks/inline.js +++ b/tasks/inline.js @@ -61,6 +61,10 @@ module.exports = function(grunt) { function isBase64Path( url ){ return url.match(/^'?data.*base64/); } + + function isInlineSVG( url ){ + return url.match(/^'?data.*svg\+xml/); + } // code from grunt-contrib-copy, with a little modification function detectDestType(dest) { @@ -187,7 +191,7 @@ module.exports = function(grunt) { fileContent = fileContent.replace(/url\(["']*([^)'"]+)["']*\)/g, function(matchedWord, imgUrl){ var newUrl = imgUrl; var flag = imgUrl.indexOf(options.tag)!=-1; // urls like "img/bg.png?__inline" will be transformed to base64 - if(isBase64Path(imgUrl) || isRemotePath(imgUrl)){ + if(isBase64Path(imgUrl) || isInlineSVG(imgUrl) || isRemotePath(imgUrl)){ return matchedWord; } grunt.log.debug( 'imgUrl: '+imgUrl); @@ -220,7 +224,7 @@ module.exports = function(grunt) { var newUrl = imgUrl; var flag = !!imgUrl.match(/\?__inline/); // urls like "img/bg.png?__inline" will be transformed to base64 grunt.log.debug('flag:'+flag); - if(isBase64Path(imgUrl) || isRemotePath(imgUrl)){ + if(isBase64Path(imgUrl) || isInlineSVG(imgUrl) || isRemotePath(imgUrl)){ return matchedWord; } grunt.log.debug( 'imgUrl: '+imgUrl);