Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"**/fonts/**",
"node_modules",
"coverage",
"*.log"
"*.log",
"test/outputs"
]
}
20 changes: 18 additions & 2 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,10 @@ function normalizePath(file) {
return path.sep === "\\" ? file.replace(/\\/g, "/") : file;
}

const reversedCharMapper = {};

// eslint-disable-next-line no-control-regex
const filenameReservedRegex = /[<>:"/\\|?*]/g;
const filenameReservedRegex = /([<>:"/\\|?*\s])/g;
Comment thread
JounQin marked this conversation as resolved.
Comment thread
JounQin marked this conversation as resolved.
// eslint-disable-next-line no-control-regex
const reControlChars = /[\u0000-\u001f\u0080-\u009f]/g;

Expand All @@ -270,7 +272,21 @@ function escapeLocalIdent(localident) {
localident
// For `[hash]` placeholder
.replace(/^((-?[0-9])|--)/, "_$1")
.replace(filenameReservedRegex, "-")
.replace(filenameReservedRegex, (_, $1) => {
// normalize Windows path `\` as unix `/` for constancy
const char = $1 === "\\" ? "/" : $1;

if (reversedCharMapper[char]) {
return reversedCharMapper[char];
}

const hex = char.charCodeAt(0).toString(16).toUpperCase();
const escaped = `\\C${hex}`;

reversedCharMapper[char] = escaped;

return escaped;
})
Comment on lines +275 to +289
Comment on lines +275 to +289
.replace(reControlChars, "-")
Comment thread
JounQin marked this conversation as resolved.
.replace(/\./g, "-"),
);
Expand Down
2 changes: 1 addition & 1 deletion test/__snapshots__/import-option.test.js.snap
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing

exports[`"import" option should jeep order of imports with 'webpackIgnore': errors 1`] = `[]`;

Expand Down
Loading
Loading