Skip to content

Commit 615b754

Browse files
committed
update normalizePath
1 parent 948da4a commit 615b754

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

packages/bundler-plugin-core/src/utils/normalizePath.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
const HASH_REGEX = /[a-f0-9]{8,}/i;
2-
const POTENTIAL_HASHES = [
3-
"[hash]",
4-
"[contenthash]",
5-
"[fullhash]",
6-
"[chunkhash]",
7-
];
2+
const POTENTIAL_HASHES = ["[contenthash", "[fullhash", "[chunkhash", "[hash"];
83

94
const escapeRegex = (string: string): string =>
105
string.replace(/[|\\{}()[\]^$+*?.]/g, "\\$&").replace(/-/g, "\\x2d");
@@ -34,8 +29,12 @@ export const normalizePath = (path: string, format: string): string => {
3429
)})`;
3530

3631
// grab the ending delimiter and create a regex group for it
37-
let endingDelimiter =
38-
format.at(match.hashIndex + match.hashString.length) ?? "";
32+
let endingDelimiter = "";
33+
[...format.slice(match.hashIndex)].forEach((char, index) => {
34+
if (char === "]") {
35+
endingDelimiter = format.at(match.hashIndex + index + 1) ?? "";
36+
}
37+
});
3938

4039
// If the ending delimiter is `[extname]` there won't be a
4140
// `.<file-extension>` so we need to replace it with a `.` for the

0 commit comments

Comments
 (0)