Skip to content

Commit 5e6f67c

Browse files
committed
also handle underscores
1 parent dc0e665 commit 5e6f67c

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,31 +86,31 @@ const tests: Test[] = [
8686
{
8787
name: "should replace '[hash:22]' with '*'",
8888
input: {
89-
path: "test.123.chunk.js",
89+
path: "test.CoScjXRp_rD9HKS--kYO73.chunk.js",
9090
format: "[name].[hash:22].chunk.js",
9191
},
9292
expected: "test.*.chunk.js",
9393
},
9494
{
9595
name: "should replace '[contenthash:22]' with '*'",
9696
input: {
97-
path: "test.123.chunk.js",
97+
path: "test.CoScjXRp_rD9HKS--kYO73.chunk.js",
9898
format: "[name].[contenthash:22].chunk.js",
9999
},
100100
expected: "test.*.chunk.js",
101101
},
102102
{
103103
name: "should replace '[fullhash:22]' with '*'",
104104
input: {
105-
path: "test.123.chunk.js",
105+
path: "test.CoScjXRp_rD9HKS--kYO73.chunk.js",
106106
format: "[name].[fullhash:22].chunk.js",
107107
},
108108
expected: "test.*.chunk.js",
109109
},
110110
{
111111
name: "should replace '[chunkhash:22]' with '*'",
112112
input: {
113-
path: "test.123.chunk.js",
113+
path: "test.CoScjXRp_rD9HKS--kYO73.chunk.js",
114114
format: "[name].[chunkhash:22].chunk.js",
115115
},
116116
expected: "test.*.chunk.js",

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ export const normalizePath = (path: string, format: string): string => {
4747

4848
// create a regex that will match the hash
4949
// potential values gathered from: https://en.wikipedia.org/wiki/Base64
50-
// added in `\-` to account for the `-` character which seems to be used by Rollup through testing
51-
const regexString = `(${leadingRegex}(?<hash>[0-9a-zA-Z\/+=-]+)${endingRegex})`;
50+
// added in `\-` and `\_` to account for the `-` `_` as they are included in the potential hashes: https://rollupjs.org/configuration-options/#output-hashcharacters
51+
const regexString = `(${leadingRegex}(?<hash>[0-9a-zA-Z/\+=_\/+=-]+)${endingRegex})`;
5252
const HASH_REPLACE_REGEX = new RegExp(regexString, "i");
5353

5454
// replace the hash with a wildcard and the delimiters

0 commit comments

Comments
 (0)