Skip to content

Commit 3528fd9

Browse files
fix(interpolateName): don't interpolated hashType without hash or contenthash (#140)
1 parent 809b690 commit 3528fd9

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

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

+7
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,13 @@ describe('interpolateName()', () => {
124124
'test content',
125125
'modal.1n8osQznuT8jOAwdzg_n.css',
126126
],
127+
// Should not interpret without `hash` or `contenthash`
128+
[
129+
'/lib/components/modal/modal.css',
130+
'[name].[md5::base64:20].[ext]',
131+
'test content',
132+
'modal.[md5::base64:20].css',
133+
],
127134
].forEach((test) => {
128135
it('should interpolate ' + test[0] + ' ' + test[1], () => {
129136
const interpolatedName = loaderUtils.interpolateName(

0 commit comments

Comments
 (0)