@@ -24,7 +24,7 @@ export function getHeaderCommand(
2424 config . get < string > ( "coder.headerCommand" ) ?. trim ( ) ||
2525 process . env . CODER_HEADER_COMMAND ?. trim ( ) ;
2626
27- return cmd ? cmd : undefined ;
27+ return cmd || undefined ;
2828}
2929
3030export function getHeaderArgs ( config : WorkspaceConfiguration ) : string [ ] {
@@ -44,16 +44,13 @@ export function getHeaderArgs(config: WorkspaceConfiguration): string[] {
4444 return [ "--header-command" , escapeSubcommand ( command ) ] ;
4545}
4646
47- // TODO: getHeaders might make more sense to directly implement on Storage
48- // but it is difficult to test Storage right now since we use vitest instead of
49- // the standard extension testing framework which would give us access to vscode
50- // APIs. We should revert the testing framework then consider moving this.
51-
52- // getHeaders executes the header command and parses the headers from stdout.
53- // Both stdout and stderr are logged on error but stderr is otherwise ignored.
54- // Throws an error if the process exits with non-zero or the JSON is invalid.
55- // Returns undefined if there is no header command set. No effort is made to
56- // validate the JSON other than making sure it can be parsed.
47+ /**
48+ * getHeaders executes the header command and parses the headers from stdout.
49+ * Both stdout and stderr are logged on error but stderr is otherwise ignored.
50+ * Throws an error if the process exits with non-zero or the JSON is invalid.
51+ * Returns undefined if there is no header command set. No effort is made to
52+ * validate the JSON other than making sure it can be parsed.
53+ */
5754export async function getHeaders (
5855 url : string | undefined ,
5956 command : string | undefined ,
@@ -90,8 +87,8 @@ export async function getHeaders(
9087 return headers ;
9188 }
9289 const lines = result . stdout . replace ( / \r ? \n $ / , "" ) . split ( / \r ? \n / ) ;
93- for ( let i = 0 ; i < lines . length ; ++ i ) {
94- const [ key , value ] = lines [ i ] . split ( / = ( .* ) / ) ;
90+ for ( const line of lines ) {
91+ const [ key , value ] = line . split ( / = ( .* ) / ) ;
9592 // Header names cannot be blank or contain whitespace and the Coder CLI
9693 // requires that there be an equals sign (the value can be blank though).
9794 if (
@@ -100,7 +97,7 @@ export async function getHeaders(
10097 typeof value === "undefined"
10198 ) {
10299 throw new Error (
103- `Malformed line from header command: [${ lines [ i ] } ] (out: ${ result . stdout } )` ,
100+ `Malformed line from header command: [${ line } ] (out: ${ result . stdout } )` ,
104101 ) ;
105102 }
106103 headers [ key ] = value ;
0 commit comments