diff --git a/lib/interpolateName.js b/lib/interpolateName.js index 60a898c..0d58da8 100644 --- a/lib/interpolateName.js +++ b/lib/interpolateName.js @@ -77,7 +77,7 @@ function interpolateName(loaderContext, name, options = {}) { // `hash` and `contenthash` are same in `loader-utils` context // let's keep `hash` for backward compatibility .replace( - /\[(?:([^[:\]]+):)?(?:hash|contenthash)(?::([a-z]+\d*))?(?::(\d+))?\]/gi, + /\[(?:([^[:\]]+):)?(?:hash|contenthash)(?::([a-z]+\d*(?:safe)?))?(?::(\d+))?\]/gi, (all, hashType, digestType, maxLength) => getHashDigest(content, hashType, digestType, parseInt(maxLength, 10)) ); diff --git a/test/interpolateName.test.js b/test/interpolateName.test.js index 77d9a17..6f67127 100644 --- a/test/interpolateName.test.js +++ b/test/interpolateName.test.js @@ -118,6 +118,12 @@ describe("interpolateName()", () => { "test content", "modal.lHP90NiApDwht3eNNIch.css", ], + [ + "/lib/components/modal/modal.css", + "[name].[md5:contenthash:base64safe:20].[ext]", + "test content", + "modal.8osQznuT8jOAwdzg_nek.css", + ], // Should not interpret without `hash` or `contenthash` [ "/lib/components/modal/modal.css",