File tree Expand file tree Collapse file tree 4 files changed +15
-11
lines changed
Expand file tree Collapse file tree 4 files changed +15
-11
lines changed Original file line number Diff line number Diff line change @@ -102,10 +102,13 @@ export class Commands {
102102 * CODER_URL or enter a new one. Undefined means the user aborted.
103103 */
104104 private async askURL ( selection ?: string ) : Promise < string | undefined > {
105- const defaultURL =
106- vscode . workspace . getConfiguration ( ) . get < string > ( "coder.defaultUrl" ) ?? "" ;
105+ const defaultURL = vscode . workspace
106+ . getConfiguration ( )
107+ . get < string > ( "coder.defaultUrl" )
108+ ?. trim ( ) ;
107109 const quickPick = vscode . window . createQuickPick ( ) ;
108- quickPick . value = selection || defaultURL || process . env . CODER_URL || "" ;
110+ quickPick . value =
111+ selection || defaultURL || process . env . CODER_URL ?. trim ( ) || "" ;
109112 quickPick . placeholder = "https://example.coder.com" ;
110113 quickPick . title = "Enter the URL of your Coder deployment." ;
111114
Original file line number Diff line number Diff line change @@ -423,7 +423,9 @@ export async function activate(ctx: vscode.ExtensionContext): Promise<void> {
423423 // Handle autologin, if not already logged in.
424424 const cfg = vscode . workspace . getConfiguration ( ) ;
425425 if ( cfg . get ( "coder.autologin" ) === true ) {
426- const defaultUrl = cfg . get ( "coder.defaultUrl" ) || process . env . CODER_URL ;
426+ const defaultUrl =
427+ cfg . get < string > ( "coder.defaultUrl" ) ?. trim ( ) ||
428+ process . env . CODER_URL ?. trim ( ) ;
427429 if ( defaultUrl ) {
428430 vscode . commands . executeCommand (
429431 "coder.login" ,
Original file line number Diff line number Diff line change @@ -123,9 +123,9 @@ describe("getHeaderCommand", () => {
123123 expect ( getHeaderCommand ( config ) ) . toBeUndefined ( ) ;
124124 } ) ;
125125
126- it ( "should return undefined if coder.headerCommand is not a string" , ( ) => {
126+ it ( "should return undefined if coder.headerCommand is a blank string" , ( ) => {
127127 const config = {
128- get : ( ) => 1234 ,
128+ get : ( ) => " " ,
129129 } as unknown as WorkspaceConfiguration ;
130130
131131 expect ( getHeaderCommand ( config ) ) . toBeUndefined ( ) ;
Original file line number Diff line number Diff line change @@ -19,11 +19,10 @@ export function getHeaderCommand(
1919 config : WorkspaceConfiguration ,
2020) : string | undefined {
2121 const cmd =
22- config . get ( "coder.headerCommand" ) || process . env . CODER_HEADER_COMMAND ;
23- if ( ! cmd || typeof cmd !== "string" ) {
24- return undefined ;
25- }
26- return cmd ;
22+ config . get < string > ( "coder.headerCommand" ) ?. trim ( ) ||
23+ process . env . CODER_HEADER_COMMAND ?. trim ( ) ;
24+
25+ return cmd ? cmd : undefined ;
2726}
2827
2928export function getHeaderArgs ( config : WorkspaceConfiguration ) : string [ ] {
You can’t perform that action at this time.
0 commit comments