Skip to content

Commit f8a71f4

Browse files
webschikevilebottnawi
authored andcommitted
fix: fixed a hash type extracting in interpolateName (#137)
1 parent 489ef12 commit f8a71f4

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
.idea
12
node_modules
23
coverage

lib/interpolateName.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ function interpolateName(loaderContext, name, options) {
9191
// `hash` and `contenthash` are same in `loader-utils` context
9292
// let's keep `hash` for backward compatibility
9393
.replace(
94-
/\[(?:([^:]+):)?(?:hash||contenthash)(?::([a-z]+\d*))?(?::(\d+))?\]/gi,
94+
/\[(?:([^:\]]+):)?(?:hash||contenthash)(?::([a-z]+\d*))?(?::(\d+))?\]/gi,
9595
(all, hashType, digestType, maxLength) =>
9696
getHashDigest(content, hashType, digestType, parseInt(maxLength, 10))
9797
)

test/interpolateName.test.js

+6
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,12 @@ describe('interpolateName()', () => {
100100
'test content',
101101
'js/filenameWithoutExt.bin',
102102
],
103+
[
104+
'/lib/components/modal/modal.css',
105+
'[name]__modalTitle___[sha1:hash:hex:4]',
106+
'test content',
107+
'modal__modalTitle___1eeb',
108+
],
103109
].forEach((test) => {
104110
it('should interpolate ' + test[0] + ' ' + test[1], () => {
105111
const interpolatedName = loaderUtils.interpolateName(

0 commit comments

Comments
 (0)