(proxyUrl: string)
| 48 | } |
| 49 | |
| 50 | function validateAndGetProxy(proxyUrl: string): string { |
| 51 | try { |
| 52 | // 使用URL构造函数验证URL格式 |
| 53 | const url = new URL(proxyUrl); |
| 54 | return url.toString(); |
| 55 | } catch (error) { |
| 56 | Container.inject(Logger).error(`Invalid proxy URL: ${proxyUrl}`, error); |
| 57 | throw new Error(`Invalid proxy URL: ${proxyUrl}`); |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | /** |
| 62 | * Checks if the client has tools capability. |