File tree 2 files changed +18
-1
lines changed
2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -73,7 +73,9 @@ String.prototype.toCommandArgumentForPythonExt = function (this: string): string
73
73
if ( ! this ) {
74
74
return this ;
75
75
}
76
- return ( this . indexOf ( ' ' ) >= 0 || this . indexOf ( '&' ) >= 0 ) && ! this . startsWith ( '"' ) && ! this . endsWith ( '"' )
76
+ return ( this . indexOf ( ' ' ) >= 0 || this . indexOf ( '&' ) >= 0 || this . indexOf ( '(' ) >= 0 || this . indexOf ( ')' ) >= 0 ) &&
77
+ ! this . startsWith ( '"' ) &&
78
+ ! this . endsWith ( '"' )
77
79
? `"${ this } "`
78
80
: this . toString ( ) ;
79
81
} ;
Original file line number Diff line number Diff line change @@ -20,6 +20,21 @@ suite('String Extensions', () => {
20
20
const argTotest = 'one two three' ;
21
21
expect ( argTotest . toCommandArgumentForPythonExt ( ) ) . to . be . equal ( `"${ argTotest } "` ) ;
22
22
} ) ;
23
+ test ( 'Should quote file paths containing one of the parentheses: ( ' , ( ) => {
24
+ const fileToTest = 'user/code(1.py' ;
25
+ expect ( fileToTest . fileToCommandArgumentForPythonExt ( ) ) . to . be . equal ( `"${ fileToTest } "` ) ;
26
+ } ) ;
27
+
28
+ test ( 'Should quote file paths containing one of the parentheses: ) ' , ( ) => {
29
+ const fileToTest = 'user)/code1.py' ;
30
+ expect ( fileToTest . fileToCommandArgumentForPythonExt ( ) ) . to . be . equal ( `"${ fileToTest } "` ) ;
31
+ } ) ;
32
+
33
+ test ( 'Should quote file paths containing both of the parentheses: () ' , ( ) => {
34
+ const fileToTest = '(user)/code1.py' ;
35
+ expect ( fileToTest . fileToCommandArgumentForPythonExt ( ) ) . to . be . equal ( `"${ fileToTest } "` ) ;
36
+ } ) ;
37
+
23
38
test ( 'Should quote command arguments containing ampersand' , ( ) => {
24
39
const argTotest = 'one&twothree' ;
25
40
expect ( argTotest . toCommandArgumentForPythonExt ( ) ) . to . be . equal ( `"${ argTotest } "` ) ;
You can’t perform that action at this time.
0 commit comments