mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 10:26:08 +01:00 
			
		
		
		
	fix buggy http proxy initialization, closes #4453
This commit is contained in:
		| @@ -160,6 +160,8 @@ function getImage(imageUrl) { | |||||||
|     }); |     }); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | const HTTP = 'http:', HTTPS = 'https:'; | ||||||
|  |  | ||||||
| function getProxyAgent(opts) { | function getProxyAgent(opts) { | ||||||
|     if (!opts.proxy) { |     if (!opts.proxy) { | ||||||
|         return null; |         return null; | ||||||
| @@ -167,15 +169,15 @@ function getProxyAgent(opts) { | |||||||
|  |  | ||||||
|     const {protocol} = url.parse(opts.url); |     const {protocol} = url.parse(opts.url); | ||||||
|  |  | ||||||
|     if (protocol === 'http:' || protocol === 'https:') { |     if (![HTTP, HTTPS].includes(protocol)) { | ||||||
|         const protoNoColon = protocol.substr(0, protocol.length - 1); |  | ||||||
|         const AgentClass = require(`${protoNoColon}-proxy-agent`); |  | ||||||
|  |  | ||||||
|         return new AgentClass(opts.proxy); |  | ||||||
|     } |  | ||||||
|     else { |  | ||||||
|         return null; |         return null; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     const AgentClass = HTTP === protocol | ||||||
|  |         ? require("http-proxy-agent").HttpProxyAgent | ||||||
|  |         : require("https-proxy-agent").HttpsProxyAgent; | ||||||
|  |  | ||||||
|  |     return new AgentClass(opts.proxy); | ||||||
| } | } | ||||||
|  |  | ||||||
| function getClient(opts) { | function getClient(opts) { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user