mirror of
https://github.com/lovell/sharp.git
synced 2025-12-19 15:25:07 +01:00
Replace deprecated URL parser
Fix up various linter errors
This commit is contained in:
@@ -20,15 +20,18 @@ function env (key) {
|
||||
|
||||
module.exports = function () {
|
||||
try {
|
||||
const proxy = url.parse(proxies.map(env).find(is.string));
|
||||
const proxy = new url.URL(proxies.map(env).find(is.string));
|
||||
const tunnel = proxy.protocol === 'https:'
|
||||
? tunnelAgent.httpsOverHttps
|
||||
: tunnelAgent.httpsOverHttp;
|
||||
const proxyAuth = proxy.username && proxy.password
|
||||
? `${proxy.username}:${proxy.password}`
|
||||
: null;
|
||||
return tunnel({
|
||||
proxy: {
|
||||
port: Number(proxy.port),
|
||||
host: proxy.hostname,
|
||||
proxyAuth: proxy.auth
|
||||
proxyAuth
|
||||
}
|
||||
});
|
||||
} catch (err) {
|
||||
|
||||
@@ -517,7 +517,7 @@ const formats = new Map([
|
||||
function toFormat (format, options) {
|
||||
const actualFormat = formats.get(is.object(format) && is.string(format.id) ? format.id : format);
|
||||
if (!actualFormat) {
|
||||
throw is.invalidParameterError('format', `one of: ${[...formats.keys()].join(`, `)}`, format);
|
||||
throw is.invalidParameterError('format', `one of: ${[...formats.keys()].join(', ')}`, format);
|
||||
}
|
||||
return this[actualFormat](options);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user