Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitbe4f2d5

Browse files
authored
[bugfix] Correct the content shown in status-bar (LeetCode-OpenSource#202)
1 parentf77737d commitbe4f2d5

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

‎src/leetCodeManager.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class LeetCodeManager extends EventEmitter {
2424
publicasyncgetLoginStatus():Promise<void>{
2525
try{
2626
constresult:string=awaitleetCodeExecutor.getUserInfo();
27-
this.currentUser=result.slice("You are now login as".length).trim();
27+
this.currentUser=this.tryParseUserName(result);
2828
this.userStatus=UserStatus.SignedIn;
2929
}catch(error){
3030
this.currentUser=undefined;
@@ -117,6 +117,16 @@ class LeetCodeManager extends EventEmitter {
117117
publicgetUser():string|undefined{
118118
returnthis.currentUser;
119119
}
120+
121+
privatetryParseUserName(output:string):string{
122+
constreg:RegExp=/^\s*.\s*(.+?)\s*https:\/\/leetcode/m;
123+
constmatch:RegExpMatchArray|null=output.match(reg);
124+
if(match&&match.length===2){
125+
returnmatch[1].trim();
126+
}
127+
128+
return"Unknown";
129+
}
120130
}
121131

122132
exportconstleetCodeManager:LeetCodeManager=newLeetCodeManager();

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp