11"use strict" ;
22Object . defineProperty ( exports , "__esModule" , { value : true } ) ;
3+ var querystring_1 = require ( "querystring" ) ;
34var loader = function ( source ) {
45 if ( this . version && Number ( this . version ) >= 2 ) {
56 try {
67 this . cacheable && this . cacheable ( ) ;
7- this . callback ( null , "module.exports = " + generateCode ( source ) ) ;
8+ this . callback ( null , "module.exports = " + generateCode ( source , querystring_1 . parse ( this . resourceQuery ) ) ) ;
89 }
910 catch ( err ) {
1011 this . emitError ( err . message ) ;
@@ -17,11 +18,20 @@ var loader = function (source) {
1718 this . callback ( new Error ( message ) ) ;
1819 }
1920} ;
20- function generateCode ( source ) {
21+ function generateCode ( source , query ) {
22+ var _a ;
2123 var code = '' ;
2224 var value = typeof source === 'string'
2325 ? JSON . parse ( source )
24- : source ;
26+ : Buffer . isBuffer ( source )
27+ ? JSON . parse ( source . toString ( ) )
28+ : null ;
29+ if ( value === null ) {
30+ throw new Error ( 'invalid source!' ) ;
31+ }
32+ if ( query . locale && typeof query . locale === 'string' ) {
33+ value = Object . assign ( { } , ( _a = { } , _a [ query . locale ] = value , _a ) ) ;
34+ }
2535 value = JSON . stringify ( value )
2636 . replace ( / \u2028 / g, '\\u2028' )
2737 . replace ( / \u2029 / g, '\\u2029' )
0 commit comments