File tree Expand file tree Collapse file tree 2 files changed +7
-0
lines changed
Expand file tree Collapse file tree 2 files changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -351,6 +351,9 @@ export class Ec2Connecter implements vscode.Disposable {
351351 * @returns bash command to remove lines from file.
352352 */
353353export function getRemoveLinesCommand ( pattern : string , hostOS : Ec2OS , filepath : string ) : string {
354+ if ( pattern . includes ( '/' ) ) {
355+ throw new ToolkitError ( `ec2: cannot match pattern containing '/', given: ${ pattern } ` )
356+ }
354357 // Linux allows not passing extension to -i, whereas macOS requires zero length extension.
355358 return `sed -i${ isLinux ( hostOS ) ? '' : " ''" } /${ pattern } /d ${ filepath } `
356359}
Original file line number Diff line number Diff line change @@ -288,4 +288,8 @@ describe('getRemoveLinesCommand', async function () {
288288 assert . ok ( ! alCommand . includes ( "''" ) )
289289 assert . strictEqual ( ubuntuCommand , alCommand )
290290 } )
291+
292+ it ( 'throws when given invalid pattern' , function ( ) {
293+ assert . throws ( ( ) => getRemoveLinesCommand ( 'pat/tern' , 'macOS' , 'test.txt' ) )
294+ } )
291295} )
You can’t perform that action at this time.
0 commit comments