File tree 2 files changed +12
-3
lines changed
2 files changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -738,9 +738,8 @@ ArgumentParser.prototype._parseOptional = function (argString) {
738
738
739
739
// if the option string before the "=" is present, return the action
740
740
if ( argString . indexOf ( '=' ) >= 0 ) {
741
- var argStringSplit = argString . split ( '=' ) ;
742
- optionString = argStringSplit [ 0 ] ;
743
- argExplicit = argStringSplit . slice ( 1 ) . join ( '=' ) ;
741
+ optionString = argString . split ( '=' , 1 ) [ 0 ] ;
742
+ argExplicit = argString . slice ( optionString . length + 1 ) ;
744
743
745
744
if ( ! ! this . _optionStringActions [ optionString ] ) {
746
745
action = this . _optionStringActions [ optionString ] ;
Original file line number Diff line number Diff line change @@ -123,6 +123,16 @@ describe('base', function () {
123
123
args = parser . parseArgs ( [ '-1' ] ) ;
124
124
assert . equal ( args . bar , - 1 ) ;
125
125
} ) ;
126
+
127
+ it ( "should parse arguments with '='" , function ( ) {
128
+ parser = new ArgumentParser ( { debug : true } ) ;
129
+ parser . addArgument ( [ '-f' , '--foo' ] ) ;
130
+ parser . addArgument ( [ 'bar' ] ) ;
131
+
132
+ args = parser . parseArgs ( '-f="foo=nice=path" "bar=nice=path"' . split ( ' ' ) ) ;
133
+ assert . equal ( args . foo , '"foo=nice=path"' ) ;
134
+ assert . equal ( args . bar , '"bar=nice=path"' ) ;
135
+ } ) ;
126
136
127
137
it ( "No negative number options; neg number is positional argument" , function ( ) {
128
138
parser = new ArgumentParser ( { debug : true } ) ;
You can’t perform that action at this time.
0 commit comments