fix: handle default ports in gateway URL validation

JavaScript's URL API omits .port for standard ports (443 for wss:,
80 for ws:) even when explicitly specified. This caused valid URLs
like wss://host.ts.net:443 to fail validation with 'Gateway URL
must include an explicit port.'

Fix by checking default ports when url.port is empty.

Closes #148
This commit is contained in:
DevBot
2026-02-21 08:56:37 +00:00
committed by Abhimanyu Saharan
parent 56fadb4b47
commit fae681747d

View File

@@ -12,7 +12,10 @@ export const validateGatewayUrl = (value: string) => {
if (url.protocol !== "ws:" && url.protocol !== "wss:") {
return "Gateway URL must start with ws:// or wss://.";
}
if (!url.port) {
// url.port is empty for default ports (80 for ws:, 443 for wss:) — allow those
const defaultPorts: Record<string, string> = { "ws:": "80", "wss:": "443" };
const effectivePort = url.port || defaultPorts[url.protocol] || "";
if (!effectivePort) {
return "Gateway URL must include an explicit port.";
}
return null;