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 {
102
102
* CODER_URL or enter a new one. Undefined means the user aborted.
103
103
*/
104
104
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 ( ) ;
107
109
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 ( ) || "" ;
109
112
quickPick . placeholder = "https://example.coder.com" ;
110
113
quickPick . title = "Enter the URL of your Coder deployment." ;
111
114
Original file line number Diff line number Diff line change @@ -423,7 +423,9 @@ export async function activate(ctx: vscode.ExtensionContext): Promise<void> {
423
423
// Handle autologin, if not already logged in.
424
424
const cfg = vscode . workspace . getConfiguration ( ) ;
425
425
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 ( ) ;
427
429
if ( defaultUrl ) {
428
430
vscode . commands . executeCommand (
429
431
"coder.login" ,
Original file line number Diff line number Diff line change @@ -123,9 +123,9 @@ describe("getHeaderCommand", () => {
123
123
expect ( getHeaderCommand ( config ) ) . toBeUndefined ( ) ;
124
124
} ) ;
125
125
126
- it ( "should return undefined if coder.headerCommand is not a string" , ( ) => {
126
+ it ( "should return undefined if coder.headerCommand is a blank string" , ( ) => {
127
127
const config = {
128
- get : ( ) => 1234 ,
128
+ get : ( ) => " " ,
129
129
} as unknown as WorkspaceConfiguration ;
130
130
131
131
expect ( getHeaderCommand ( config ) ) . toBeUndefined ( ) ;
Original file line number Diff line number Diff line change @@ -19,11 +19,10 @@ export function getHeaderCommand(
19
19
config : WorkspaceConfiguration ,
20
20
) : string | undefined {
21
21
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 ;
27
26
}
28
27
29
28
export function getHeaderArgs ( config : WorkspaceConfiguration ) : string [ ] {
You can’t perform that action at this time.
0 commit comments