Files
2025-09-08 04:48:28 +08:00

8 lines
207 B
TypeScript
Executable File

/**
* Extract port from a URL string
*/
export function getPortFromUrl(url: string): string {
const parsedUrl = new URL(url);
return parsedUrl.port || (parsedUrl.protocol === 'https:' ? '443' : '80');
}