mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-09 08:30:06 -04:00
27 lines
601 B
TypeScript
27 lines
601 B
TypeScript
import { URL } from 'node:url'
|
|
|
|
type ProxyParserResult = {
|
|
protocol: string | null
|
|
auth: {
|
|
username: string | null
|
|
password: string | null
|
|
}
|
|
host: string
|
|
port: number | null
|
|
}
|
|
|
|
export class ProxyParser {
|
|
parse(_url: string): ProxyParserResult {
|
|
const parsed = new URL(_url)
|
|
|
|
return {
|
|
protocol: parsed.protocol.replace(':', '') || null,
|
|
auth: {
|
|
username: parsed.username || null,
|
|
password: parsed.password || null
|
|
},
|
|
host: parsed.hostname,
|
|
port: parsed.port ? parseInt(parsed.port) : null
|
|
}
|
|
}
|
|
}
|