Skip to content
This repository has been archived by the owner on Oct 9, 2020. It is now read-only.

Commit

Permalink
fix: don't transform webpack2 query objects
Browse files Browse the repository at this point in the history
  • Loading branch information
agerard-godaddy authored and joshwiens committed Jul 16, 2017
1 parent 7186951 commit 9373e3e
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ var simpleHTMLTokenizer = require('simple-html-tokenizer');
var tokenize = simpleHTMLTokenizer.tokenize;
var generate = simpleHTMLTokenizer.generate;
var loaderUtils = require('loader-utils');
var assign = require('object-assign');

var conditions = require('./lib/conditions');
var transformer = require('./lib/transformer');
Expand All @@ -20,15 +21,20 @@ var regexSequences = [
];

function getExtractedSVG(svgStr, query) {
var config;
// interpolate hashes in classPrefix
if(!!query && !!query.classPrefix) {
const name = query.classPrefix === true ? '__[hash:base64:7]__' : query.classPrefix;
query.classPrefix = loaderUtils.interpolateName({}, name, {content: svgStr});
}
if(!!query) {
config = assign({}, query);

if (!!config.classPrefix) {
const name = config.classPrefix === true ? '__[hash:base64:7]__' : config.classPrefix;
config.classPrefix = loaderUtils.interpolateName({}, name, { content: svgStr });
}

if (!!query && !!query.idPrefix) {
const id_name = query.idPrefix === true ? '__[hash:base64:7]__' : query.idPrefix;
query.idPrefix = loaderUtils.interpolateName({}, id_name, {content: svgStr});
if (!!config.idPrefix) {
const id_name = config.idPrefix === true ? '__[hash:base64:7]__' : config.idPrefix;
config.idPrefix = loaderUtils.interpolateName({}, id_name, { content: svgStr });
}
}

// Clean-up XML crusts like comments and doctype, etc.
Expand All @@ -47,7 +53,7 @@ function getExtractedSVG(svgStr, query) {
}

// If the token is <svg> start-tag, then remove width and height attributes.
return generate(transformer.runTransform(tokens, query));
return generate(transformer.runTransform(tokens, config));
}

function SVGInlineLoader(content) {
Expand Down

0 comments on commit 9373e3e

Please sign in to comment.