Update scripts

This commit is contained in:
freearhey
2025-07-17 17:43:00 +03:00
parent 35a4b24bce
commit 2787186700
8 changed files with 44 additions and 15 deletions

View File

@@ -2,9 +2,9 @@ import { URL } from 'node:url'
type ProxyParserResult = {
protocol: string | null
auth: {
username: string | null
password: string | null
auth?: {
username?: string
password?: string
}
host: string
port: number | null
@@ -14,14 +14,18 @@ export class ProxyParser {
parse(_url: string): ProxyParserResult {
const parsed = new URL(_url)
return {
const result: ProxyParserResult = {
protocol: parsed.protocol.replace(':', '') || null,
auth: {
username: parsed.username || null,
password: parsed.password || null
},
host: parsed.hostname,
port: parsed.port ? parseInt(parsed.port) : null
}
if (parsed.username || parsed.password) {
result.auth = {}
if (parsed.username) result.auth.username = parsed.username
if (parsed.password) result.auth.password = parsed.password
}
return result
}
}