fix: support VLESS xhttp and normalize IPv6 addresses

This commit is contained in:
wonfen
2026-07-17 23:51:29 +08:00
parent 950e8195fb
commit b7978705af
7 changed files with 42 additions and 7 deletions
+5 -1
View File
@@ -193,6 +193,10 @@ export type UrlLikeParts = {
fragment?: string
}
export function normalizeHost(host: string): string {
return host.startsWith('[') && host.endsWith(']') ? host.slice(1, -1) : host
}
const URLLIKE_RE =
/^(?:(?<auth>.*?)@)?(?<host>.*?)(?::(?<port>\d+))?\/?(?:\?(?<query>.*?))?(?:#(?<fragment>.*?))?$/
@@ -227,7 +231,7 @@ export function parseUrlLike(
const result: UrlLikeParts = {
auth,
host: groups.host,
host: normalizeHost(groups.host),
port: groups.port,
query: groups.query,
fragment: groups.fragment,