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 @@ -741,9 +741,8 @@ ArgumentParser.prototype._parseOptional = function (argString) {
741
741
742
742
// if the option string before the "=" is present, return the action
743
743
if ( argString . indexOf ( '=' ) >= 0 ) {
744
- var argStringSplit = argString . split ( '=' ) ;
745
- optionString = argStringSplit [ 0 ] ;
746
- argExplicit = argStringSplit [ 1 ] ;
744
+ optionString = argString . split ( '=' , 1 ) [ 0 ] ;
745
+ argExplicit = argString . slice ( optionString . length + 1 ) ;
747
746
748
747
if ( ! ! this . _optionStringActions [ optionString ] ) {
749
748
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