From fa04b7e9da292aa4fc81f44991b84d52c2f274d7 Mon Sep 17 00:00:00 2001 From: Juan Diego Moreno Upegui Date: Tue, 4 Nov 2025 14:53:44 -0500 Subject: [PATCH] added feature that allows client to work directly with ip and ports --- src/client.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/client.ts b/src/client.ts index 8d3e94f..08b12d6 100644 --- a/src/client.ts +++ b/src/client.ts @@ -45,6 +45,9 @@ export class TrytonClient { /** * Create a new Tryton client + * @param config Configuration object + * @param config.hostname - Hostname or IP address. Can include port (e.g., "46.62.242.210:8090") + * @param config.port - Port number (ignored if hostname includes port) */ constructor(config: TrytonClientConfig) { const { @@ -69,10 +72,20 @@ export class TrytonClient { this.useHttps = port === 443 || port === 8443; } + // Handle IP:Port format (e.g., "46.62.242.210:8090") + if (this.hostname.includes(":") && !this.hostname.startsWith("http")) { + const [ip, hostPort] = this.hostname.split(":"); + this.hostname = ip; + this.port = parseInt(hostPort, 10); + // Determine https based on extracted port + this.useHttps = this.port === 443 || this.port === 8443; + } else { + this.port = port; + } + this.database = database; this.username = username; this.password = password || ""; // Empty string if not provided - this.port = port; this.language = language; this.options = options; this.connection = null; @@ -81,6 +94,7 @@ export class TrytonClient { /** * Alternative constructor for backward compatibility + * Note: If hostname includes port (IP:Port), the port parameter will be ignored */ static create( hostname: string,