improved urlHostnameToIPv6

This commit is contained in:
BPplays 2024-12-30 02:59:41 -08:00
parent 7744be3319
commit f67abf9e03

View File

@ -693,10 +693,10 @@ export function isValidUrl(url) {
}
export function urlHostnameToIPv6(hostname) {
if (hostname.charAt(0) === '[') {
if (hostname.startsWith("[")) {
hostname = hostname.slice(1);
}
if (hostname.charAt(hostname.length - 1) === ']') {
if (hostname.endsWith("]")) {
hostname = hostname.slice(0, -1);
}
return hostname