From 07cff878e5dba997d04ffcd03a7fa06b058b232f Mon Sep 17 00:00:00 2001 From: BPplays Date: Sun, 29 Dec 2024 04:20:39 -0800 Subject: [PATCH] commited util --- src/util.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/util.js b/src/util.js index 13176f46e..1bd870ea1 100644 --- a/src/util.js +++ b/src/util.js @@ -692,6 +692,23 @@ export function isValidUrl(url) { } } +export function urlHostnameToIPv6(hostname) { + if (hostname.charAt(0) === '[') { + hostname = hostname.slice(1); + } + if (hostname.charAt(hostname.length - 1) === ']') { + hostname = hostname.slice(0, -1); + } + // console.log(hostname) + return hostname +} + +export function stringToBool(str) { + if (str === 'true') return true; + if (str === 'false') return false; + return str; +} + /** * MemoryLimitedMap class that limits the memory usage of string values. */