mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-09 08:30:06 -04:00
Create proxyParser.ts
This commit is contained in:
parent
3f22ac12f5
commit
e02e46562a
1 changed files with 27 additions and 0 deletions
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue