Skip to content

Commit

Permalink
fix(plugin): properly replace paths on Windows
Browse files Browse the repository at this point in the history
Fixes #106
  • Loading branch information
kisenka committed May 10, 2017
1 parent 630d80d commit 0c70caa
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/utils/replace-sprite-placeholder.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
const escapeRegExpSpecialChars = require('escape-string-regexp');

const isWindows = /^win/i.test(process.platform);

/**
* @param {string} content
* @param {Object<string, string>} replacements
Expand All @@ -9,9 +11,10 @@ function replaceSpritePlaceholder(content, replacements) {
let result = content;
Object.keys(replacements)
.map((subj) => {
const normalizedSubj = isWindows ? subj.replace(/\\/g, '\\\\') : subj;
return {
subj,
re: new RegExp(escapeRegExpSpecialChars(subj), 'g')
re: new RegExp(escapeRegExpSpecialChars(normalizedSubj), 'g')
};
})
.forEach(({ subj, re }) => {
Expand Down

0 comments on commit 0c70caa

Please sign in to comment.