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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 7 additions & 0 deletions
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy