@@ -84,16 +84,33 @@ exports.normalizeTypes = function(types){
8484 */ 
8585
8686function  acceptParams  ( str )  { 
87-   var  parts  =  str . split ( /   * ;   * / ) ; 
88-   var  ret  =  {  value : parts [ 0 ] ,  quality : 1 ,  params : { }  } 
87+   var  length  =  str . length ; 
88+   var  colonIndex  =  str . indexOf ( ';' ) ; 
89+   var  index  =  colonIndex  ===  - 1  ? length  : colonIndex ; 
90+   var  ret  =  {  value : str . slice ( 0 ,  index ) . trim ( ) ,  quality : 1 ,  params : { }  } ; 
8991
90-   for  ( var  i  =  1 ;  i  <  parts . length ;  ++ i )  { 
91-     var  pms  =  parts [ i ] . split ( /   * =   * / ) ; 
92-     if  ( 'q'  ===  pms [ 0 ] )  { 
93-       ret . quality  =  parseFloat ( pms [ 1 ] ) ; 
92+   while  ( index  <  length )  { 
93+     var  splitIndex  =  str . indexOf ( '=' ,  index ) ; 
94+     if  ( splitIndex  ===  - 1 )  break ; 
95+ 
96+     var  colonIndex  =  str . indexOf ( ';' ,  index ) ; 
97+     var  endIndex  =  colonIndex  ===  - 1  ? length  : colonIndex ; 
98+ 
99+     if  ( splitIndex  >  endIndex )  { 
100+       index  =  str . lastIndexOf ( ';' ,  splitIndex  -  1 )  +  1 ; 
101+       continue ; 
102+     } 
103+ 
104+     var  key  =  str . slice ( index ,  splitIndex ) . trim ( ) ; 
105+     var  value  =  str . slice ( splitIndex  +  1 ,  endIndex ) . trim ( ) ; 
106+ 
107+     if  ( key  ===  'q' )  { 
108+       ret . quality  =  parseFloat ( value ) ; 
94109    }  else  { 
95-       ret . params [ pms [ 0 ] ]  =  pms [ 1 ] ; 
110+       ret . params [ key ]  =  value ; 
96111    } 
112+ 
113+     index  =  endIndex  +  1 ; 
97114  } 
98115
99116  return  ret ; 
0 commit comments