|
2 | 2 | // Licensed under the MIT license. |
3 | 3 |
|
4 | 4 | import { commands, ViewColumn } from "vscode"; |
5 | | -import { IProblem } from "../shared"; |
| 5 | +import { getLeetCodeEndpoint } from "../commands/plugin"; |
| 6 | +import { Endpoint, IProblem } from "../shared"; |
6 | 7 | import { ILeetCodeWebviewOption, LeetCodeWebview } from "./LeetCodeWebview"; |
7 | 8 | import { markdownEngine } from "./markdownEngine"; |
8 | 9 |
|
@@ -180,21 +181,18 @@ class LeetCodePreviewProvider extends LeetCodeWebview { |
180 | 181 | } |
181 | 182 |
|
182 | 183 | private getDiscussionLink(url: string): string { |
183 | | - if (url.includes("leetcode-cn.com")) { |
| 184 | + const endPoint: string = getLeetCodeEndpoint(); |
| 185 | + if (endPoint === Endpoint.LeetCodeCN) { |
184 | 186 | return url.replace("/description/", "/comments/"); |
185 | | - } else if (url.includes("leetcode.com")) { |
| 187 | + } else if (endPoint === Endpoint.LeetCode) { |
186 | 188 | return url.replace("/description/", "/discuss/?currentPage=1&orderBy=most_votes&query="); |
187 | 189 | } |
188 | 190 |
|
189 | 191 | return "https://leetcode.com"; |
190 | 192 | } |
191 | 193 |
|
192 | 194 | private getSolutionLink(url: string): string { |
193 | | - if (url.includes("leetcode-cn.com") || url.includes("leetcode.com")) { |
194 | | - return url.replace("/description/", "/solution/"); |
195 | | - } |
196 | | - |
197 | | - return "https://leetcode.com"; |
| 195 | + return url.replace("/description/", "/solution/"); |
198 | 196 | } |
199 | 197 | } |
200 | 198 |
|
|
0 commit comments