Skip to content

Commit 0c70caa

Browse files
committed
fix(plugin): properly replace paths on Windows
Fixes #106
1 parent 630d80d commit 0c70caa

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

lib/utils/replace-sprite-placeholder.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
const escapeRegExpSpecialChars = require('escape-string-regexp');
22

3+
const isWindows = /^win/i.test(process.platform);
4+
35
/**
46
* @param {string} content
57
* @param {Object<string, string>} replacements
@@ -9,9 +11,10 @@ function replaceSpritePlaceholder(content, replacements) {
911
let result = content;
1012
Object.keys(replacements)
1113
.map((subj) => {
14+
const normalizedSubj = isWindows ? subj.replace(/\\/g, '\\\\') : subj;
1215
return {
1316
subj,
14-
re: new RegExp(escapeRegExpSpecialChars(subj), 'g')
17+
re: new RegExp(escapeRegExpSpecialChars(normalizedSubj), 'g')
1518
};
1619
})
1720
.forEach(({ subj, re }) => {

0 commit comments

Comments
 (0)