tiny-essentials
Version:
Collection of small, essential scripts designed to be used across various projects. These simple utilities are crafted for speed, ease of use, and versatility.
20 lines • 1.04 kB
text/typescript
/**
* @function getDomainURL
*
* Constructs a full URL string from a domain and optional port, determining the proper protocol.
* It also supports extracting the domain from an Express `req` object via `checkDomain.get(req)`.
*
* @param {string|import('express').Request} domain - A domain string (e.g. "example.com") or Express `req` object.
* @param {number} [port] - Optional port to include in the URL (not added for ports 80 or 443).
* @param {string} [httpResult='https'] - The protocol to use (usually "http" or "https").
*
* @returns {string} A fully constructed URL string. Returns an empty string if the domain is invalid.
* @deprecated
*
* @example
* getDomainURL('example.com', 443); // "https://example.com"
* getDomainURL('localhost', 3000); // "http://localhost:3000"
* getDomainURL(req, 8080); // Uses domain from request object
*/
export default function getDomainURL(domain: string | import("express").Request, port?: number, httpResult?: string): string;
//# sourceMappingURL=getDomainURL.d.mts.map