fix(unifi): port is ignored (#2995)

This commit is contained in:
Meier Lukas
2025-05-01 12:51:20 +02:00
committed by GitHub
parent 4dfde2ba05
commit 0c9c5b8955
3 changed files with 62 additions and 7 deletions

View File

@@ -21,3 +21,20 @@ export const extractBaseUrlFromHeaders = (
return `${protocol}://${host}`;
};
export const getPortFromUrl = (url: URL): number => {
const port = url.port;
if (port) {
return Number(port);
}
if (url.protocol === "https:") {
return 443;
}
if (url.protocol === "http:") {
return 80;
}
throw new Error(`Unsupported protocol: ${url.protocol}`);
};