88import  type  {  Errors  }  from  '..' 
99import  Validator  from  './Validator' 
1010import  {  hasFiles ,  objectToFormData ,  removeDoubleSlash  }  from  '../util' 
11- import  qs ,  {  ParsedQs  }  from  'qs' 
11+ import  qs ,  {  IParseOptions  }  from  'qs' 
12+ import  merge  from  'lodash.merge' 
1213
1314const  validator  =  Validator 
1415const  UNPROCESSABLE_ENTITY  =  422 
@@ -21,8 +22,13 @@ class BaseProxy {
2122  public  errors : Errors 
2223  public  parameters : any  |  any [ ] 
2324  public  readonly  endpoint : string 
24-   public  static  $http : AxiosInstance   |   undefined 
25+   public  static  $http ? : AxiosInstance 
2526  public  static  $errorProperty  =  'errors' 
27+   public  static  $parsedQs : IParseOptions  =  { 
28+     comma : true , 
29+     allowDots : true , 
30+     ignoreQueryPrefix : true , 
31+   } 
2632
2733  constructor ( endpoint : string ,  parameters ?: ParametersType )  { 
2834    this . endpoint  =  endpoint 
@@ -38,6 +44,10 @@ class BaseProxy {
3844    return  BaseProxy . $errorProperty 
3945  } 
4046
47+   get  $parsedQs ( )  { 
48+     return  BaseProxy . $parsedQs 
49+   } 
50+ 
4151  /** 
4252   * Get all or by pagination 
4353   */ 
@@ -228,7 +238,7 @@ class BaseProxy {
228238  } 
229239
230240  private  static  __validateRequestType ( requestType : Method ) : string  { 
231-     const  requestTypes : Array < string >  =  [ 
241+     const  requestTypes : string [ ]  =  [ 
232242      'get' , 
233243      'delete' , 
234244      'head' , 
@@ -263,12 +273,12 @@ class BaseProxy {
263273   */ 
264274  setParameter ( parameter : string ,  value ?: any ) : this { 
265275    if  ( ! value )  { 
266-       const  options   =  { 
276+       const  options :  IParseOptions   =   merge ( this . $parsedQs ,  { 
267277        comma : true , 
268278        allowDots : true , 
269279        ignoreQueryPrefix : true , 
270-       } 
271-       const  params :  ParsedQs  =  qs . parse ( parameter ,  options ) 
280+       } ) 
281+       const  params  =  qs . parse ( parameter ,  options ) 
272282      return  this . setParameters ( params ) 
273283    } 
274284    this . parameters [ parameter ]  =  value 
@@ -283,9 +293,9 @@ class BaseProxy {
283293    if  ( ! parameters . length )  { 
284294      this . parameters  =  [ ] 
285295    }  else  { 
286-       parameters . forEach ( ( parameter )   =>  { 
296+       for   ( const   parameter   of   parameters )  { 
287297        delete  this . parameters [ parameter ] 
288-       } ) 
298+       } 
289299    } 
290300    return  this 
291301  } 
0 commit comments