Skip to content

Commit 1e1d8a0

Browse files
committed
fix: replace discuss->solution in solution URL
1 parent d713ad5 commit 1e1d8a0

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/webview/leetCodeSolutionProvider.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,23 @@ class LeetCodeSolutionProvider extends LeetCodeWebview {
7777
[solution.author, raw] = raw.match(/\* Author:\s+(.+)\n([^]+)/)!.slice(1);
7878
[solution.votes, raw] = raw.match(/\* Votes:\s+(\d+)\n\n([^]+)/)!.slice(1);
7979
solution.body = raw;
80+
81+
solution.url = replaceUrlDiscussWithSolution(solution.url);
82+
8083
return solution;
8184
}
8285
}
8386

87+
function replaceUrlDiscussWithSolution(url: string): string {
88+
// This is due to the update of leetcode.com on 2022 Dec
89+
// "vsc-leetcode-cli": "2.8.1" is still using "discuss" instead of "solutions" in URL
90+
// this will have the vsc-leetcode-cli updating URL to "solutions"
91+
return url.replace(
92+
/https:\/\/leetcode.com\/problems\/(.+)\/discuss\/(\d+)/,
93+
"https://discuss.leetcode.com/problem/$1/solutions/$2"
94+
);
95+
}
96+
8497
// tslint:disable-next-line:max-classes-per-file
8598
class Solution {
8699
public title: string = "";

0 commit comments

Comments
 (0)