diff --git a/.gitignore b/.gitignore
index ba2a97b..428a1df 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,3 @@
+.idea
node_modules
coverage
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7fa1fd1..8b6c762 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,16 @@
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
+
+## [1.2.2](https://github.com/webpack/loader-utils/compare/v1.2.1...v1.2.2) (2018-12-27)
+
+
+### Bug Fixes
+
+* fixed a hash type extracting in interpolateName ([#137](https://github.com/webpack/loader-utils/issues/137)) ([f8a71f4](https://github.com/webpack/loader-utils/commit/f8a71f4))
+
+
+
## [1.2.1](https://github.com/webpack/loader-utils/compare/v1.2.0...v1.2.1) (2018-12-25)
diff --git a/lib/interpolateName.js b/lib/interpolateName.js
index 7aa69bc..cfe2ec0 100644
--- a/lib/interpolateName.js
+++ b/lib/interpolateName.js
@@ -91,7 +91,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*))?(?::(\d+))?\]/gi,
(all, hashType, digestType, maxLength) =>
getHashDigest(content, hashType, digestType, parseInt(maxLength, 10))
)
diff --git a/package.json b/package.json
index 98690a9..2a14883 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "loader-utils",
- "version": "1.2.1",
+ "version": "1.2.2",
"author": "Tobias Koppers @sokra",
"description": "utils for webpack loaders",
"dependencies": {
diff --git a/test/interpolateName.test.js b/test/interpolateName.test.js
index 20df069..05b59f7 100644
--- a/test/interpolateName.test.js
+++ b/test/interpolateName.test.js
@@ -100,6 +100,30 @@ describe('interpolateName()', () => {
'test content',
'js/filenameWithoutExt.bin',
],
+ [
+ '/lib/components/modal/modal.css',
+ '[name]__modalTitle___[sha1:hash:hex:4]',
+ 'test content',
+ 'modal__modalTitle___1eeb',
+ ],
+ [
+ '/lib/components/modal/modal.css',
+ '[name]__modalTitle___[sha1:contenthash:hex:4]',
+ 'test content',
+ 'modal__modalTitle___1eeb',
+ ],
+ [
+ '/lib/components/modal/modal.css',
+ '[name].[md5:hash:base64:20].[ext]',
+ 'test content',
+ 'modal.1n8osQznuT8jOAwdzg_n.css',
+ ],
+ [
+ '/lib/components/modal/modal.css',
+ '[name].[md5:contenthash:base64:20].[ext]',
+ 'test content',
+ 'modal.1n8osQznuT8jOAwdzg_n.css',
+ ],
].forEach((test) => {
it('should interpolate ' + test[0] + ' ' + test[1], () => {
const interpolatedName = loaderUtils.interpolateName(