File tree Expand file tree Collapse file tree 3 files changed +10
-0
lines changed
Expand file tree Collapse file tree 3 files changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -329,6 +329,9 @@ export class Options {
329329 return '' ;
330330 }
331331
332+ // people often accidentally enter their API Key into the API Url settings input
333+ if ( ! Utils . validateApiUrl ( apiUrl ) ) apiUrl = '' ;
334+
332335 if ( ! apiUrl ) {
333336 try {
334337 apiUrl = await this . getSettingAsync < string > ( 'settings' , 'api_url' ) ;
Original file line number Diff line number Diff line change @@ -30,6 +30,12 @@ export class Utils {
3030 return '' ;
3131 }
3232
33+ public static validateApiUrl ( url : string ) : string {
34+ if ( ! url ) return '' ;
35+ if ( url . startsWith ( 'http://' ) || url . startsWith ( 'https://' ) ) return url . trim ( ) ;
36+ return '' ;
37+ }
38+
3339 public static validateProxy ( proxy : string ) : string {
3440 if ( ! proxy ) return '' ;
3541 let re ;
Original file line number Diff line number Diff line change @@ -256,6 +256,7 @@ export class WakaTime {
256256 placeHolder : 'https://api.wakatime.com/api/v1' ,
257257 value : apiUrl ,
258258 ignoreFocusOut : true ,
259+ validateInput : Utils . validateApiUrl . bind ( this ) ,
259260 } ;
260261 vscode . window . showInputBox ( promptOptions ) . then ( ( val ) => {
261262 if ( val ) {
You can’t perform that action at this time.
0 commit comments