3xworkaround
Version:
This is an interface for 3x-ui panel. It will help developers to create, edit and delete inbounds and clients in a simple way.
22 lines (21 loc) • 638 B
JavaScript
import urljoin from "url-join";
export const decodeUri = (uri) => {
const url = new URL(encodeURI(uri));
const protocol = url.protocol.slice(0, -1);
const host = url.hostname;
const defaultPort = protocol === "https" ? 443 : 80;
const port = url.port.length ? Number(url.port) : defaultPort;
const path = url.pathname;
const username = decodeURIComponent(url.username);
const password = decodeURIComponent(url.password);
const endpoint = urljoin(url.origin, path);
return {
protocol,
host,
port,
path,
username,
password,
endpoint,
};
};