mirror of
https://github.com/iptv-org/epg
synced 2025-12-16 10:26:41 -05:00
Create proxyParser.ts
This commit is contained in:
27
scripts/core/proxyParser.ts
Normal file
27
scripts/core/proxyParser.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user