File tree 1 file changed +15
-7
lines changed
1 file changed +15
-7
lines changed Original file line number Diff line number Diff line change @@ -215,20 +215,28 @@ var util = {
215
215
parse : function string ( ini ) {
216
216
var currentSection , map = { } ;
217
217
util . arrayEach ( ini . split ( / \r ? \n / ) , function ( line ) {
218
- line = line . split ( / ( ^ | \s ) [ ; # ] / ) [ 0 ] ; // remove comments
219
- var section = line . match ( / ^ \s * \[ ( [ ^ \[ \] ] + ) \] \s * $ / ) ;
220
- if ( section ) {
221
- currentSection = section [ 1 ] ;
218
+ line = line . split ( / ( ^ | \s ) [ ; # ] / ) [ 0 ] . trim ( ) ; // remove comments and trim
219
+ var isSection = line [ 0 ] === '[' && line [ line . length - 1 ] === ']' ;
220
+ if ( isSection ) {
221
+ currentSection = line . substring ( 1 , line . length - 1 ) ;
222
222
if ( currentSection === '__proto__' || currentSection . split ( / \s / ) [ 1 ] === '__proto__' ) {
223
223
throw util . error (
224
224
new Error ( 'Cannot load profile name \'' + currentSection + '\' from shared ini file.' )
225
225
) ;
226
226
}
227
227
} else if ( currentSection ) {
228
- var item = line . match ( / ^ \s * ( .+ ?) \s * = \s * ( .+ ?) \s * $ / ) ;
229
- if ( item ) {
228
+ var indexOfEqualsSign = line . indexOf ( '=' ) ;
229
+ var start = 0 ;
230
+ var end = line . length - 1 ;
231
+ var isAssignment =
232
+ indexOfEqualsSign !== - 1 && indexOfEqualsSign !== start && indexOfEqualsSign !== end ;
233
+
234
+ if ( isAssignment ) {
235
+ var name = line . substring ( 0 , indexOfEqualsSign ) . trim ( ) ;
236
+ var value = line . substring ( indexOfEqualsSign + 1 ) . trim ( ) ;
237
+
230
238
map [ currentSection ] = map [ currentSection ] || { } ;
231
- map [ currentSection ] [ item [ 1 ] ] = item [ 2 ] ;
239
+ map [ currentSection ] [ name ] = value ;
232
240
}
233
241
}
234
242
} ) ;
You can’t perform that action at this time.
0 commit comments