feat: support the `[query]` template for the `interpolatedName` metho… · webpack/loader-utils@469eeba
@@ -131,10 +131,58 @@ describe('interpolateName()', () => {
131131'test content',
132132'modal.[md5::base64:20].css',
133133],
134+[
135+'/app/js/javascript.js?foo=bar',
136+'js/[hash].script.[ext][query]',
137+'test content',
138+'js/9473fdd0d880a43c21b7778d34872157.script.js?foo=bar',
139+],
140+[
141+'/app/js/javascript.js?foo=bar&bar=baz',
142+'js/[hash].script.[ext][query]',
143+'test content',
144+'js/9473fdd0d880a43c21b7778d34872157.script.js?foo=bar&bar=baz',
145+],
146+[
147+'/app/js/javascript.js?foo',
148+'js/[hash].script.[ext][query]',
149+'test content',
150+'js/9473fdd0d880a43c21b7778d34872157.script.js?foo',
151+],
152+[
153+'/app/js/javascript.js?',
154+'js/[hash].script.[ext][query]',
155+'test content',
156+'js/9473fdd0d880a43c21b7778d34872157.script.js',
157+],
158+[
159+'/app/js/javascript.js?a',
160+'js/[hash].script.[ext][query]',
161+'test content',
162+'js/9473fdd0d880a43c21b7778d34872157.script.js?a',
163+],
164+[
165+'/app/js/javascript.js?foo=bar#hash',
166+'js/[hash].script.[ext][query]',
167+'test content',
168+'js/9473fdd0d880a43c21b7778d34872157.script.js?foo=bar',
169+],
134170].forEach((test) => {
135171it('should interpolate ' + test[0] + ' ' + test[1], () => {
172+let resourcePath = '';
173+let resourceQuery = '';
174+175+const queryIdx = test[0].indexOf('?');
176+177+if (queryIdx >= 0) {
178+resourcePath = test[0].substr(0, queryIdx);
179+resourceQuery = test[0].substr(queryIdx);
180+} else {
181+resourcePath = test[0];
182+}
183+136184const interpolatedName = loaderUtils.interpolateName(
137-{ resourcePath: test[0] },
185+{ resourcePath, resourceQuery },
138186test[1],
139187{ content: test[2] }
140188);